What are the advantages of C#?-> C#
provides operator overloading which is not available in VB.NET
-> C# allows you to access memory directly using unsafe code blocks -> If you use unmanaged resources in your program, then garbage collector will not dispose it. For disposing unmanaged resources, C# permits you to use "using" statement -> C# allows you to implement an interface in a base class and re-implement the interface in the derived class and provide a new definition for it C# permits nested classes which are not allowed in C and C++ -> C# establishes better event management using delegates -> C# allows you to document your code using XML documentation -> C# gets rid of complex registry lookups and problems due to IDispatch, IUnknown of COM by introducing the concept of namespaces -> C# supports cross-language interoperability with any .NET language -> C# supports conditional compilation -> Most important advantage of C# is the reflection mechanism. Consider the following example: class sampleClass { public void sampleMethod() { Console.WriteLine("Invoking sampleMethod of sampleClass"); } } Now you have
to invoke and execute the method sampleMethod of sampleClass. How do you
do it? Here is the normal way of coding which all of you might perform: C# provides
an advanced feature called reflection mechanism using which you can invoke
sampleMethod as shown below: This is just
a simple example, reflection mechanism can be used to establish dynamic
behavior and determine all properties and methods of an object at runtime
and much more.
|