Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

This video shows who are the design team behind the most popular .NET language - C#. The team talk about a brief background of C# 4.0. What will be in there and where the language is going. Read the post here.

using XL = Microsoft.Office.Interop.Excel;

void CreateExcel()

{

string filename = @"C:\ExcelThroughCSharp.xls";

// create an instance of EXCEL application

XL.Application app = new XL.Application();

app.Visible = true;

app.DisplayAlerts = true;

// add workbook

XL.Workbook wb = app.Workbooks.Add(XL.XlWBATemplate.xlWBATWorksheet);

// the wb workbook already has 1 worksheet

// add second worksheet after the first one

wb.Worksheets.Add(Type.Missing, wb.Worksheets[wb.Worksheets.Count], Type.Missing, Type.Missing);

// add second worksheet after the second one

wb.Worksheets.Add(Type.Missing, wb.Worksheets[wb.Worksheets.Count], Type.Missing, Type.Missing);

// get the second worksheet

XL.Worksheet sheet = (XL.Worksheet)wb.Worksheets[2];

// write some value

sheet.Cells[2, 2] = "test value from c# code";

// change worksheet's name

sheet.Name = "modified sheet";

// close and save the workbook

wb.Close(true, filename, null);

// release the worksheet resources

if (sheet != null)

{

System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);sheet = null;

}

// release the workbook resources

if (wb != null)

{

System.Runtime.InteropServices.Marshal.ReleaseComObject(wb);wb = null;

}

// release the excel instance resources

if (app != null)

{

app.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComObject(app);

app = null;

}

// Clean up memory so Excel can shut down.

GC.Collect(); GC.WaitForPendingFinalizers();

// The GC needs to be called twice in order to get the

// Finalizers called - the first time in, it simply makes

// a list of what is to be finalized, the second time in,

// it actually the finalizing. Only then will the

// object do its automatic ReleaseComObject.

GC.Collect();GC.WaitForPendingFinalizers();

}

CREDITS: http://bytes.com/forum/thread475347.html

A new developer tool was released by Microsoft - it is the Source Analysis for C#.

The ultimate goal of Source Analysis is to allow you to produce elegant, consistent code that your team members and others who view your code will find highly readable. In order to accomplish this, Source Analysis does not allow its rules to be very configurable. Source Analysis takes a one-size-fits-all approach to code style, layout, and readability rules. It is highly likely that you will not agree with all of the rules and may even find some of the rules annoying at first! However, the majority of teams using this tool within Microsoft have found that after a short adjustment period, they came to appreciate the rules enforced by Source Analysis, and even began to find it difficult to read code not written in this style.

Rules that this Source Analysis checks includes:

  • Layout of elements, statements, expressions, and query clauses
  • Placement of curly brackets, parenthesis, square brackets, etc
  • Spacing around keywords and operator symbols
  • Line spacing
  • Placement of method parameters within method declarations or method calls
  • Standard ordering of elements within a class
  • Formatting of documentation within element headers and file headers
  • Naming of elements, fields and variables
  • Use of the built-in types
  • Use of access modifiers
  • Allowed contents of files
  • Debugging text

 A dedicated blog for Source Analysis for C# can be found here and the tool can be downloaded here.

If you want to integrate the tool with MSBuild, an explanation can be found here.