C# .Cs Extension: Run/build
C# .Cs Extension: Run/build
cs extension
Run/build
File -> project -> console app C# select version
*.cs C# compiler *.d
ll (Dynamic Link Library)
Shortcut Keys
Copy Ctrl C Show Quick- fixes Alt Enter Find in File Ctrl F
Paste Ctrl V Save File Ctrl S Find in all Ctrl Shift F
Cut Ctrl X See all Ctrl Shift S Replace Ctrl H
Duplicate Ctrl D Quick Watch Shift F9 Replace in all Ctrl Shift H
Select all Ctrl A Toggle Breakpoint F9 Go back Ctrl -
Rename Ctrl R R Step over F10 Mouse
Comment Ctrl K C Step into F11 Go to def Ctrl click
Uncomment Ctrl K U Undo Change Ctrl Z Multiline select Alt Drag
Code cleanup Ctrl K D Redo Change Ctrl Y
String interpolation is a feature in C# that allows you to embed expressions or variables directly within a string literal.
int x = 10; int y = 5;
string result = $"The sum of {x} and {y} is {x + y}.";
Console.WriteLine(result);
*************************************************************************************************
Drawback of single
using System;
using System.Threading;
namespace MultiThreadingInCSharp
{
class ProgramP
{
static void Main(string[] args)
{
Method1();
Console.WriteLine("MEthod 1 execution is completed");
Method2();
Console.WriteLine("Method 2 execution is completed");
Method3();
Console.WriteLine("MEthod 3 execution is completed");
//Single thread
//Thread t =Thread.CurrentThread;
//t.Name = "Main Thread";
//Console.WriteLine($"Thread name {t.Name}");
//Console.WriteLine("My current thread-"+ Thread.CurrentThread.Name);
}
static void Method1()
{
for (int i = 1; i <= 5; i++)
{
Console.WriteLine("Method 1 :" + i);
}
}
static void Method2()
{
for (int i = 1; i <= 5; i++)
{
Console.WriteLine("Method 2 :" + i);
if (i == 2) { Console.WriteLine("executing code Started");
Thread.Sleep(10000);
Console.WriteLine("executing code Completed");
}
}
}
static void Method3()
{
for (int i = 1; i <= 5; i++)
{
Console.WriteLine("Method 3 :" + i);
}
}
}
}Its using single thread its going line by line
***********************************MULTITHREAD**************************************************
using System;
using System.Threading;
namespace MultiThreadingInCSharp
{
class ProgramP
{
static void Main(string[] args)
{
//Creating Threads
Thread t1 = new Thread(Method1)
{
Name = "Thread 1"
};
Thread t2 = new Thread(Method2);
t2.Name = "Thread 2";
}
}