MSDEVBUILD - Community of Microsoft AI, Azure and Xamarin by Suthahar - Solution Architect for Microsoft AI, Azure, Xamarin | Tech Author and Speaker
Singleton
|
Static Class
| |
1
|
Single means single object across the application
life cycle so it application level
|
The static does not have any Object pointer, so the scope is at App Domain level.
|
2
|
Singleton is a pattern and not a keyword
|
Static is key word
|
3
|
A Singleton can implement interfaces and inherit from other classes and allow inheritance.
|
Static class allows only static methods
and you cannot pass static class as parameter.
Static class cannot inherit their instance members
|
4
| Singleton Objects stored on heap memory
| Static class stored in stack memory
|
5
| Singleton Objects can have constructor
|
|
6
| Singleton Objects can dispose
| We can’t dispose in static class
|
7
| Singleton Objects can clone
| We can’t clone in static class
|
C# 5.0
|
C# 6.0
|
Value[first] =”Nikhile”
|
Value. $first = “Nikhil”
|
C# 5.0
|
C# 6.0
|
try
{ }
catch (Exception ex)
{ }
|
Try {
throw new Exception("Null Error");
}
catch (Exception ex) if (ex.Message == " IndexError")
{
// this one will not execute.
}
catch (Exception ex) if (ex.Message == " Null Error ")
{
// this one will execute
}
|
C# 5.0
|
C# 6.0
|
try
{
DoSomething();
}
catch (Exception)
{
//Its not Support here
await LogService.LogAsync(ex);
}
|
try
{
DoSomething();
}
catch (Exception)
{
// New feature it will support
await LogService.LogAsync(ex);
}
|
C# 5.0
|
C# 6.0
|
Int Qty;
Int.TryParse(txtnumber.Text, out Qty)
|
Int.TryParse(txtnumber.Text, Int out Qty)
|
C# 5.0
|
C# 6.0
|
Dictionary
{
{ "India", "TN" },
{ "United States", "Washington" },
{ "Some Country", "Some Capital " }
};
|
Dictionary
{
// Look at this!
["Afghanistan"] = "Kabul",
["Iran"] = "Tehran",
["India"] = "Delhi"
};
|
C# 5.0
|
C# 6.0
|
public static string Truncate(string value, int length)
{
string result = value;
//this pain work for us
if (value != null) // Skip empty string check for elucidation
{
result = value.Substring(0, Math.Min(value.Length, length));
}
return result;
}
|
public static string Truncate(string value, int length)
{
return value?.Substring(0, Math.Min(value.Length, length));
}
|
Features
|
Web Service
|
WCF
|
Hosting
|
It can be hosted in IIS
|
It can be hosted in IIS, windows activation service, Self-hosting, Windows service
|
Programming
|
[WebService] attribute has to be added to the class
|
[ServiceContraact] attribute has to be added to the class
|
Model
|
[WebMethod] attribute represents the method exposed to client
|
[OperationContract] attribute represents the method exposed to client
|
Operation
|
One-way, Request- Response are the different operations supported in web service
|
One-Way, Request-Response, Duplex are different type of operations supported in WCF
|
XML
|
System.Xml.serialization name space is used for serialization
|
System.Runtime.Serialization namespace is used for serialization
|
Encoding
|
XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom
|
XML 1.0, MTOM, Binary, Custom
|
Transports
|
Can be accessed through HTTP, TCP, Custom
|
Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
|
Protocols
|
Security
|
Security, Reliable messaging, Transactions
|
During development and everyday use, Substring is often the go-to choice for string manipulation. However, there are cases where Substring c...