Composition vs Aggregation in C#

Arjun Thakur
Published on 17-Sep-2018 11:33:33
CompositionUnder Composition, if the parent object is deleted, then the child object also loses its status. Composition is a special type of Aggregation and gives a part-of relationship.For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.public class Engine {    . . ... Read More

Complex Numbers in C#

karthikeya Boyini
Published on 17-Sep-2018 11:33:31
To work WITH and display complex numbers in C#, you need to check for real and imaginary values.A complex number like 7+5i is formed up of two parts, a real part 7, and an imaginary part 5. Here, the imaginary part is the multiple of i.To display complete numbers, use ... Read More

Compilation and Execution of a C# Program

Chandu yadav
Published on 17-Sep-2018 11:29:48
To compile and execute a program in C#, you just need to click the Run button or press F5 key to execute the project in Microsoft Visual Studio IDE. Compile a C# program by using the command-line instead of the Microsoft Visual Studio IDE − Open a text editor ... Read More

Comparison of Java and .NET

Samual Sam
Published on 17-Sep-2018 11:28:00
Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. .NET framework is a computer software framework invented by Microsoft. It runs on Microsoft Windows OS (Operating ... Read More

C# Enum GetValues Method

Arjun Thakur
Published on 14-Sep-2018 18:34:15
Get the array of the values of the constants in a specified enumeration.Here is our enum.enum Rank { Jack = 10, Tom = 19, Tim = 26 };Now, get all the values of the enum as an array and display using GetValues() method.foreach(int res in Enum.GetValues(typeof(Rank))) {    Console.WriteLine(res); }Let ... Read More

C# Program to get the type of the specified Enumeration

Samual Sam
Published on 14-Sep-2018 18:34:00
Use the GetType() method to get the type of the enumeration.The enumeration.Enum[] values = { ConsoleColor.Blue, DayOfWeek.Sunday};Now to get the type, use the GetType() method.Type enumType = val.GetType();The following is an example that displays the type.Example Live Demousing System; public class Demo {    public static void Main() {     ... Read More

C# Enum GetNames Method

Chandu yadav
Published on 14-Sep-2018 18:30:04
The GetNames() returns the array of names of the constants in the Enumeration.The following is the enum.enum Stock { Watches, Books, Grocery };To get the array of names, use the GetNames() and loop through as shown below −foreach(string s in Enum.GetNames(typeof(Stock))) { }Let us see the complete example now.Example Live Demousing ... Read More

C# Enum GetName Method

karthikeya Boyini
Published on 14-Sep-2018 18:29:47
The GetName() method returns the names of the constants in the Enumeration.Here is the enum.enum Stock { Appliance, Clothing, Footwear };Now, get the names using the Enum.GetName() method. Just set the constant and retrieve the individual name.Enum.GetName(typeof(Stock), 1Let us see the example now.Example Live Demousing System; class Demo {    enum ... Read More

Create a Quadruple Tuple in C#

George John
Published on 14-Sep-2018 18:27:09
Quadruple is a tuple with four items.<T1, T2, T3, T4>Create a tuple first.var myTuple = Tuple.Create(100, 200, 300, 400);Above, we have created a tuple with four items i.e. Quadruple. Now to access all the four items.myTuple.Item1 myTuple.Item2 myTuple.Item3 myTuple.Item4Example Live Demousing System; public class Program {    public static void Main() ... Read More

Tuple Rest Property in C#

Samual Sam
Published on 14-Sep-2018 18:26:18
Create tuples of eight or more elements by nesting tuple objects in the Rest property.The tuple would look like −Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>Above, the 8th element is added using Rest property.Let us see an example.Example Live Demousing System; public class Program {    public static void Main() ... Read More