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) ...
Primary Key:-
It is used to provide a unique and not null value to a particular column.
The primary key must be defined in Table.
Primary key will be one in one table and it is eligible for the foreign key to providing referential integrity constraint.
Create Table tablename(columnname datatype primary key,...)
Create Table tablename(columnname int primary key auto_increment,...)
.................................................................................................................................................
Unique:-
It is only used to define unique value, unique can be multiple in one table, a single null value will be allowed in unique key.
Create Table Tablename(columnname datayype unique)
.....................................................................................................................................................
Foreign key:-
The primary key of the Master table will be integrated into the child table to provide referential integrity constraint.
A foreign key can be repeatable and null.
Create table table1(col1 int primary key,...) //Master Table
create table table2(col1 int primary key,col2 int foreign key references table1(col1)); //Child Table
Country and state table:-
countryid will be primary key and this countryid will be used in state table as a foreign key.
if we create foreign key then the foreign key column value will be dependent on primary key column value of the master table.
countryid countryname
10 IND
20 USA
null AUS //wrong because null value not allowed
20 ENG //wrong because primary key value should be unique
stateid statename countryid
101 MP 10
102 UP 10
103 AP null
104 HP 40 //wrong because of 40 not present in the master table
Comments
Post a Comment
POST Answer of Questions and ASK to Doubt