Posts

Static Constructor Example

/// /// A static constructor is used to initialize any static data, or to perform a particular action that /// needs performed once only. It is called automatically before the first instance is created or any /// static members are referenced. /// /// -A static constructor does not take access modifiers or have parameters. /// -A static constructor is called automatically to initialize the class before the first instance is created /// or any static members are referenced. /// -A static constructor cannot be called directly. /// -The user has no control on when the static constructor is executed in the program. /// -A typical use of static constructors is when the class is using a log file and the constructor is used /// to write entries to this file. /// -Static constructors are also useful when creating wrapper classes for unmanaged code, when the constructor /// can call the LoadLibrary ...

Sealed Class Example

/// /// Sealed Class /// /// You can Initiate the class /// You can not Inherit the class : class B : A { } /// Structs are implicitly sealed; therefore, they cannot be inherited. /// System.Threading.Thread /// /// sealed class A { public A() { } public void Test1() { } public static void Test2() { } } /*//Error : 'OOPS_Sealed.Program.B': cannot derive from sealed type 'OOPS_Sealed.Program.A' class B : A { }*/ static void Main(string[] args) { A obj = new A(); A.Test2(); }

Go through Static class example

/// /// Static Class /// /// You can not Initiate : A obj = new A(); /// You can not Inherited : class B : A { } /// All the members in Static class are static /// They cannot contain Instance Constructors : public A { } /// /// static class A { /* Error 'test': cannot declare instance members in a static class public void test() { } */ public static void test() { } } /*Error cannot derive from static class 'OOPS_Concept.Program.A' class B : A { } */ static void Main(string[] args) { /* Error 1 Cannot declare variable of static type 'OOPS_Concept.Program.A' Error 2 Cannot create an instance of the static class 'OOPS_Concept.Program.A' ...

In Windows application Tag Property of radio button (controls) is useful as like value field of controls in web Application

I don't have so much experience in windows application.. at that time i have gone through internet for Value Filed property of Controls in windows application. but i haven't find any link then i have gone through Property windows of Radio Button (any control).then I used that TAG property like a value field as we are using in web application. I used it in one of my desktop application.see this one of the step of XML Operation(XMLNodeIterator) for eg. rbButton.Tag = (object)xNodeIterator.Current.GetAttribute("ansId", "");

How to get motherboard serial number, Processor ID, VolumeSerialNumber using C#?

Add using System.Management; namespace in your application then //Get motherboard's serial number ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_BaseBoard"); foreach (ManagementObject mo in mbs.Get()) { textBox1.Text = mo["SerialNumber"].ToString(); } //Get Processor's Identity mbs = new ManagementObjectSearcher("Select * From Win32_processor"); foreach (ManagementObject mo in mbs.Get()) { textBox2.Text = mo["ProcessorID"].ToString(); } //Get Network Adapter Configuration mbs = new ManagementObjectSearcher("Select * From Win32_NetworkAdapterConfiguration"); foreach (ManagementObject mo in mbs.Get()) { textBox3.Text = mo["MACAddress"].ToString(); break; } ...

Building and Consuming XML web services

Creating Web Service using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class HelloHeader : SoapHeader { public string Username; public string Password; } public class HelloSoapHeader : System.Web.Services.WebService { public HelloHeader myHeader; [WebMethod] [SoapHeader("myHeader")] public string HelloWorld() { System.Threading.Thread.Sleep(1000); if (myHeader == null) return "Hello World"; else return "Hello " + myHeader.Username + " Your Password is :" + myHeader.Password; } } Consumming web service Synchronously using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.U...

Web page execution

This article is copied from http://www.c-sharpcorner.com/UploadFile/hima_.net/WebPageExecutioninIIS05162006054117AM/WebPageExecutioninIIS.aspx How the Simple Web page execution Happens? As All of us know A Request comes from Client (Browser) and sends to Server (We call it as Web server) in turn Server Process the Request and sends response Back to the Client in according to the client Request But internally in the Web server there is quite interesting process that happens. To get aware of that process we should first of all know about the architecture of the IIS It mainly consists of 3 Parts/Files 1. Inetinfo.exec 2. ISAPI Filter (Container for Internet Server Application Interface dlls) , 3. Worker Process (aspnet_wp.exe) When ever a Request comes from the Client: Inetinfo.exe is the ASP.Net Request Handler that handles the requests from the client .If it’s for static resources like HTML files or image files inetinfo.exe process the request and sent to client If th...