An interface is similar to a class with method signatures. There wont be any implementation of the methods in Interface. Classes which implements interface should have implementation of methods defined in abstract class
Friday, February 20, 2015
Sealed Classes in c#
If a class is defined as Sealed it cannot be inherited in derived class.
public sealed class Car { public Car() { Console.WriteLine("Base Class Car"); } public void DriveType() { Console.WriteLine("Right Hand "); } }
Abstract Class in C#
If we don't want a class object to be created define the class as abstract. An abstract class can have abstract and non abstract classes. If a method in abstract id defined as abstract , it must be implemented in derived class. For example , in the classes given below , method DriveType is defined as abstract.
abstract class Car { public Car() { Console.WriteLine("Base Class Car"); } public abstract void DriveType(); } class Ford : Car { public void DriveType() { Console.WriteLine("Right Hand "); } }
Method Hiding in C#
If the derived class doesn't want to use methods in base class , derived class can implement the same method in derived class with same signature. For example in the classes given below, DriveType() is implemented in the derived class with same signature. This is called Method Hiding.
class Car { public void DriveType() { Console.WriteLine("Right Hand Drive"); } } class Ford : Car { public void DriveType() { Console.WriteLine("Right Hand "); } }
Monday, February 16, 2015
Javascript How to get unique values in a array
var a = ["1", "1", "2", "3", "3", "1"];
var unique = a.filter(function(item, i, ar){ return ar.indexOf(item) === i; });
asp.net access values from dictionary
IDictionary<string, object> keyValueCollection //- Dictionary variable
KeyValuePair<string, object> escalateres;
escalateres = keyValueCollection.Where(x => x.Key.ToLower().Trim() == "escalateres" &&
null != x.Value && x.Value.ToString() != "All").FirstOrDefault(); //access values of key "escalateres"
List<object> lstEscalatersDetails = null; //define list variable
lstEscalatersDetails = escalateres.Value as List<object>;
foreach (object lstEscalatersDetail in lstEscalatersDetails)
{
IDictionary<string, object> keyValueCollectionHelpDeskEcalatorTime = new Dictionary<string, object>();
keyValueCollectionHelpDeskEcalator = lstEscalatersDetail as IDictionary<string, object>;
FormatEscalateTime = Convert.ToString(keyValueCollectionHelpDeskEcalator["Hrs"]) + ":" + Convert.ToString(keyValueCollectionHelpDeskEcalator["Mins"]);
KeyValuePair<string, object> EscalateTime = new KeyValuePair<string, object>("EscalateTime", FormatEscalateTime);
keyValueCollectionHelpDeskEcalatorTime.Add(EscalateTime);
keyValueCollectionHelpDeskEcalatorTime.Add("HelpDeskSLAId", id);
Save(keyValueCollectionHelpDeskEcalatorTime, "HelpDeskEscalators");
}
Friday, February 13, 2015
ASP.NET Remove value from Dictionary
keyValueCollection.Remove("ResolvedHrs");
keyValueCollection.Remove("ResolvedMin");
keyValueCollection.Remove("ResolvedMin");
Subscribe to:
Posts (Atom)