C# is a modern, general-purpose, object-oriented programming language developed by Microsoft and approved by European Computer Manufacturers Association (ECMA) and International Standards Organization (ISO). C# was developed by Anders Hejlsberg and his team during the development of .Net Framework. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows use of various high-level languages on different computer platforms and architectures.
C# a widely used professional language for : · It is a modern, general-purpose programming language · It is object oriented. · It is component oriented. · It is easy to learn. · It is a structured language. · It produces efficient programs. · It can be compiled on a variety of computer platforms. · It is a part of .Net Framework.
Here is a list of types of applications C# can build,
- Windows client applications
- Windows libraries and components
- Windows services
- Web applications
- Web services and Web API
- Native IOS and Android mobile apps
- Backend services
- Azure cloud applications and services
- Backend database using ML/Data tools
- Interoperability software such as Office, SharePoint, SQL Server and so on.
- Artificial Intelligence and Machine learning
- Blockchains and distributed ledger technology including cryptocurrency
- Internet of Things (IoT) devices
- Gaming consoles and gaming systems
- Video games
C # programming
Using Class / Object Method-
———
using System;
public class mm
{
public void disp()
{
Console.WriteLine(“using method”);
}
}
public class Program
{
public static void Main()
{
mm m=new mm();
m.disp();
}
}
————————
Parameterized method
———————–
using System;
public class mm
{
public void disp(int a)
{
Console.WriteLine(“square value {0}”,a*a);
}
}
public class Program
{
public static void Main()
{
mm m=new mm();
m.disp(5);
}
}
—————
Constructor & Parameterized Constructor
—————
using System;
public class mm
{
public mm(int a)
{
Console.WriteLine(“square value {0}”,a*a);
}
}
public class Program
{
public static void Main()
{
mm m=new mm(4);
}
}
——————————————–
using System;
public class mm
{
public mm(int a)
{
Console.WriteLine(“square value {0}”,a*a);
}
}
public class Program
{
public static void Main()
{
Console.WriteLine(“Enter your no “);
int x=Convert.ToInt32(Console.ReadLine());
mm m=new mm(x);
}
}
# Even /odd no
using System;
public class mm
{
public mm(int a)
{
if (a%2==0)
Console.WriteLine(“Even no {0}”,a);
else
Console.WriteLine(“odd no {0}”,a);
}
}
public class Program
{
public static void Main()
{
Console.WriteLine(“Enter your no “);
int x=Convert.ToInt32(Console.ReadLine());
mm m=new mm(x);
} }
# Method overloading
using System;
public class mm
{
public void disp(int a)
{
if (a%2==0)
Console.WriteLine(“Even no {0}”,a);
else
Console.WriteLine(“odd no {0}”,a);
}
public void disp(int a, int b)
{
if(a>b)
Console.WriteLine(“Greater no {0}”,a);
else
Console.WriteLine(“Greater no {0}”,b);
}
public void disp(double n)
{
double m=n*n;
Console.WriteLine(“Square value is {0}”,m);
}
}
public class Program
{
public static void Main()
{
mm m=new mm();
m.disp(5);
m.disp(5,7);
m.disp(4.5);
}
}
# An enum is a value type with a set of related named constants often referred to as an enumerator list. The enum keyword is used to declare an enumeration. It is a primitive data type, which is user defined.
using System;
public class EnumTest
{
enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
public static void Main()
{
int x = (int)Days.Sun;
int y = (int)Days.Fri;
Console.WriteLine(“Sun = {0}”, x);
Console.WriteLine(“Fri = {0}”, y);
}
}
Inheritance –
Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes.
using System;
public class ss
{
public void disp()
{
Console.WriteLine(“using simple inheritance”);
}
}
public class mm :ss
{
public void show()
{
Console.WriteLine(“using sub class”);
}
}
public class Program
{
public static void Main()
{
mm m=new mm();
m.disp();
m.show();
Console.WriteLine(“program completed”);
}
}