Friday 27 December 2019

ternary operator in C#

 this is a ? : Ternary Operator
it is return one of two values depending on Boolean condition 
Syntax:
condition ? expressionIfTrue : expressionIfFalse;
Example:
string name = "hamid";
Console.WriteLine(name == "hamid" ? "The name is hamid" : "The name is not hamid");

so it will return : The name is hamid

Console.WriteLine(name == "hamidXYZ" ? "The name is hamid" : "The name is not hamid");
so it will return : The name is not hamid

How To Implement NLog In WebAPI

I have created my blog here please view for full details in step by step

https://www.c-sharpcorner.com/article/how-to-implement-nlog-in-webapi/

How To Create EXE For .Net Core Console Application

I have created my blog here please view for full details in step by step

https://www.c-sharpcorner.com/article/how-to-create-exe-for-net-cor/

class vs structure


class
1- Class is a reference types.
2- Class uses new keyword for instance.
3- reference type is stored in heap memory.
4- Class can have constructor or destructor.

Struct
1- it is value type
2- it is not using new keyword
3- value type stored in stack memory
4- it do not have constructor or destructor

create your console application in C#

difference between String and string in C#?

1- technically, there is no difference.
2- string is an alias for System.String
3- others alias are as follows
   object:  System.Object
string:  System.String
bool:    System.Boolean
byte:    System.Byte
sbyte:   System.SByte
short:   System.Int16
ushort:  System.UInt16
int:     System.Int32
uint:    System.UInt32
long:    System.Int64
ulong:   System.UInt64
float:   System.Single
double:  System.Double
decimal: System.Decimal
char:    System.Char

top 10 commands in .net core cli

1-dotnet new console -o test
  it will create a console project in the directory test
2- dotnet restore
3- dotnet build
4- dotnet run
5- dotnet test
6- dotnet pack
7- dotnet clean
8- dotnet sln
9- dotnet add/remove reference
10-dotnet add/remove package