Posts

difference between array and array list in c#

1.The capacity of an  Array   is fixed.  Where as,  ArrayList   can increase and decrease size dynamically.   2.An  Array   is a collection of similar items.  Where as,  ArrayList   can hold item of different types.   3.Array is in the System namespace.  Where as, ArrayList is in the System.Collections namespace.   4.An  Array   can have multiple dimensions.  Where as,  ArrayList   always has exactly one dimension.   We can set the lower bound of an  Array .  Where as, the lower bound of an  ArrayList   is always zero.     Array   is faster and that is because  ArrayList   uses a fixed amount of array.  However when you add an element to the  ArrayList   and it overflows. It creates a new  Array   and copies every element from the old one to the new one.  You will only feel this if you add to often.

difference between var and dynamic c#

  Programming languages can normally be considered to be either statically typed or dynamically typed. A static (not to be confused with the static keyword, used for classes) typed language validates the syntax or checks for any errors during the compilation of the code. On the other hand, dynamically typed languages validate the syntax or checks for errors only at run time. For example, C# and Java are a static type and JavaScript is a dynamically typed language. C# was previously considered to be a statically typed language, since all the code written was validated at the compile time itself. But, with the introduction of the dynamic keyword in C# 4.0, it became a dynamic typed language also. The two concepts of static and dynamic types in C# can be illustrated with the use of the two keywords named var and dynamic. Let's discuss some basic differences between these two, based on some of their characteristics. When were they introduced var was int

abstract class and interface difference c#

Abstract Class & interfaces Q:In what scenarios will you use a abstract class and in what scenarios will you use a interface? •      If you want to increase reusability in inheritance then abstract classes are good.  •      If you want implement or force some methods across classes must be for uniformity you can use a interface. •      So to increase reusability via inheritance use abstract class as it is nothing but a base class and to force methods use interfaces. Some points about an Abstract Class are: 1.      We cannot create an object of an Abstract Class. 2.      An Abstract Class can be inherited with its derived class. 3.      Can have both concrete and abstract methods but at least one abstract method is compulsory in an Abstract Class. 4.      An Abstract Class is used as a base class for projects. 5.      An Abstract Class can inherit another base class and base interfaces. 6.      The constructor of an Abstract Class can be called through the derived class

data annotation attributes c#

 C# DataAnnotation   Attributes 1.Required 2.StringLengtgh 3.DisplayName 4.Range 5.Compare 6.ScaffoldColumn 7.RegularExpression 8.EmailAddress 9.Url 10.Remote 11.MinLength 12.MaxLength 13.DataType 14. custom dataAnnotation Attribute Required : Ensures that a property has been assigned some value. Range : Ensures that a property value falls within a minimum and maximum value. StringLength : Can be used to check the length of a string property. You can either specify maximum permissible length or maximum and minimum permissible length. EmailAddress : Validates that an email address with a valid email format has been supplied as a property value. Url : Validates that a valid URL has been supplied as a property value. RegularExpression : Uses a regular expression to ensure that a property value matches the specified pattern. Example using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotation

how to install windows service in c#

Image
Introduction:  Here I will explain how to install windows service and how to start the windows service in our local machine. Description:  In previous article I explained clearly how to create windows service  and how to run windows service in scheduled intervals. Now I will explain how to install windows service in our system. To install windows service in your follow these steps Start  -->   All Programs   -->   Microsoft Visual Studio 2008  -->   Visual Studio Tools   -->   Open Visual Studio Command Prompt After open command prompt point to your  windowsservice.exe  file in your project Initially in our command prompt we are able to see path like this C:\Program Files\ Microsoft Visual Studio 9.0\VC >  This path is relating to our visual studio installation path because during installation if you give different path this path should be different now we can move to folder which contains our  windowsservice.exe file. After moving to ex

how to create windows service setup in c#.net

Image
how to create Windows Service in c#. Introduction :   Here I will explain what windows service is, uses of windows service and how to create windows service in c#. What is Windows Service ? Windows Services are applications that run in the background and perform various tasks.  The applications do not have a user interface or produce any visual output. Windows Services are started automatically when computer is booted. They do not require a logged in user in order to execute and can run under the context of any user including the system. Windows Services are controlled through the Service Control Manager where they can be stopped, paused, and started as needed. Create a Windows Service   Creating Windows Service is very easy with visual studio just follow the below steps to create windows service Open visual studio -->  Select  File  -->  New   --> Project -->  select  Windows Service And give name as  WinServiceSample After give  W