namespace Home { namespace Hall { class Television { } class Furniture { } namespace DiningRoom { class Furniture { } class Color { Furniture DiningFurniture; // Hall.DiningRoom.Furniture (Because of higher priority) Hall.Furniture HallFurniture; // Hall.Furniture } } } }
namespace Home.Hall.Television { class Channel1 { } } namespace Home.Hall.Television { class Channel2 { } }
namespace Home.Hall.Television { class Channel1 { } }
namespace Home.Hall.Television { class Channel2 { } }
using Home.Hall.DiningRoom; class MyClass { static void Main() { Furniture Chairs, Tables; // Refering Furniture type from the namespace above. } }
int x = 10, y = 5; if (x == y) { Console.WriteLine("Both x and y are equal...."); } else { Console.WriteLine("Both x and y are not equal...."); }
string Name = "Krishna"; switch (Name) { case "Krishna": // This case will be executed... ...............; break; case "Vamshi": ...............; break; default: ...............; break; }
int x = 3; do { Console.WriteLine(a); // This will print from 3 to 8 (because of while) a++; } while (a < 9);
for (int i = 1; i < 9; i++) { Console.WriteLine(i); // This will print from 1 to 8 }
foreach (char t in "Dotnetfunda") { Console.WriteLine(t); // This will prints all the 't's present in that string }
class MyClass { protected virtual void Test() // Virtual method declaration { ..............; ............; } } class SubClass : MyClass { protected override void Test() // overriding method from 'MyClass' class { ..............; ............; } }
const string Site = "DotNetFunda"; // Declaration of constant field Site = "ITFunda"; // Compile time error
public static event EvtHandler MyEvent; // EvtHandler must have been specified outside by using 'delegate' keyword. static void Main() { MyEvent = new EvtHandler(MeetFriends); //Adding notification to the event MyEvent.Invoke(); //Invoking the event } static void MeetFriends() { ..........; .........; }
Math.Equals(....)
int x = 5; // Assignment Expression : x = 5 x = x + 10; // Assignment Expression : x = 15