New Warning CS1060 in C# 3 (Visual Studio 2008)

Recompiling C# 2 (Visual Studio 2005) code in C# 3 (Visual Studio 2008), you may incounter a new warning that didn’t used to ocur: Warning CS1060: Use of        possibly unassigned field ‘fieldName’. Struct instance variables are initially unassigned if struct is unassigned. Dealing strictly with syntax, C# let’s you declare a value type (struct) with a reference member, for example: namespace Examples{    using System.Drawing;    public static class Program    {        public static void Main()        {            LabelEntry labelEntry;            labelEntry.Location.Point.X = 0;        }    }     public struct LabelEntry    {        public LabelLocation Location;        public String Label;    … Continue reading New Warning CS1060 in C# 3 (Visual Studio 2008)

New warning CS0809 in C# 3 (Visual Studio 2008)

There were several breaking changes (fixes) in C# 3 from C# 2.  One is the ability to attribute a member override with ObsoleteAttribute without also attributing it the virtual member in the base class. For example, the following will compile without error In C# 2 (Visual Studio 2005/.NET 2.0): using System; internal class BaseClass{    public virtual void Method()    {    }} internal class DerivedClass : BaseClass{    [Obsolete]    public override void Method()    {    }} public static class Progam{    public static void Main()    {        BaseClass baseClass = new DerivedClass();        baseClass.Method();    }} This same code will generate a CS0809 warning with C# 3. This change … Continue reading New warning CS0809 in C# 3 (Visual Studio 2008)