Features of C# 14.0 🧩 1️⃣ Field-backed Properties (0:40 – 1:00) Pehla feature hai — Field-backed Properties Ab aapko manually private field likhne ki zarurat nahi. C# 14 mein ek naya contextual keyword aaya hai — field public string Name { get ; set => field = value ?? throw new ArgumentNullException( nameof ( value )); } Yahaan field compiler-generated backing field ko represent karta hai. Validation ya logic likhna ab super easy ho gaya hai! 🧩 2️⃣ Extension Members (1:00 – 1:25) Dusra feature — Extension Members Pehle hum sirf extension methods bana sakte the, ab hum properties , events , aur static members bhi extend kar sakte hain! public static class StringExtensions { public static int WordCount ( this string str) => str.Split( ' ' ).Length; } Ab koi bhi string par .WordCount() laga ke result le sakte ho — reusability aur readability dono badh gayi! 💪 🧩 3️⃣ Null-Conditional Assignment (1:25 – 1:50) ...
what are the boxing and unboxing concept in c#:-
Unboxing means to convert Object type data to Value type for example if we convert Object to int, char, float then it is called Unboxing.it is also called explicit conversion in c# because it will manually convert the value.
using System;
class Boxing
{
public static void Main()
{
object o;
int b=100,c;
o=b; //boxing
Console.WriteLine(o);
c=(int)o; //Unboxing
Console.WriteLine(c);
}
}
Boxing means to convert primitive type data to object type for example if we convert int, char, float to Object then it is called boxing.it is also called implicit conversion in c# because it will automatically convert the value.
Unboxing means to convert Object type data to Value type for example if we convert Object to int, char, float then it is called Unboxing.it is also called explicit conversion in c# because it will manually convert the value.
using System;
class Boxing
{
public static void Main()
{
object o;
int b=100,c;
o=b; //boxing
Console.WriteLine(o);
c=(int)o; //Unboxing
Console.WriteLine(c);
}
}
Comments
Post a Comment
POST Answer of Questions and ASK to Doubt