Month End Sale: Get Extra 10% OFF on Job-oriented Training! Offer Ending in
D
H
M
S
Get Now

C# Miscellaneous Types

Level : Advanced
Mentor: Shailendra Chauhan
Duration : 00:02:30

Anonymous Type:

Anonymous types in C# allow you to create objects with properties defined at compile-time without specifying a named class. They are often used for ad-hoc data structures.

Example:

var person = new { Name = "Mohan", Age = 30 };
Console.WriteLine($"Name: {person.Name}, Age: {person.Age}");

Var Type:

The 'var' keyword is used to implicitly declare variables, letting the compiler determine the data type based on the assigned value.

Example:

var number = 42;
Console.WriteLine($"Number is of type: {number.GetType()}");

Dynamic Type:

The 'dynamic' keyword allows you to create variables whose type is determined at runtime, providing flexibility but sacrificing compile-time type checking.

Example:

dynamic value = 10;
Console.WriteLine($"Dynamic value: {value}");
value = "Hello";
Console.WriteLine($"Dynamic value: {value}");

Tuple:

Tuples allow you to group multiple values of different types into a single data structure.

Example:

var personInfo = Tuple.Create("John", 30);
Console.WriteLine($"Name: {personInfo.Item1}, Age: {personInfo.Item2}");
Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this