Hii friends,Today one of my frend ask about what approach is better connected or disconnected architecture ..So let me explain more about this problem :-As the nature of HTTP protocol,.Net web applications are always disconnected so your problem is about connected or disconnected data models."connected" data is always faster as compare to "disconnected"...
What do you meant by Containment in C#?
Containment is the replacement of inheritence,no no if inheritance isn’t the right choice,then the answer is containment, also known as aggregation. Rather than saying that an object is an example of another object, an instance of that other object will be contained inside the object. So,instead of having a class look like a string, the class will...
How to handle generic errors in WinApp using C# ?
Pass your exception or error through catch block to this method this will catch your error and show the messagebox regarding that error.Method which take error exception as a parameter and handle that error.public static void LogError(Exception ex){string sourceName = "Application Name";int errorCode = "99";string message = "The application encountered...
What is interface and why we implement interfaces ?
Interface defined by using interface keyword .In visualstudio you can directly add class as a interface its not a class it behaves as a template of the class. Interfaces describe a group of related functionalities that can belong to any class or struct.Interfaces are provided in C# as a replacement of multiple inheritance because C# does not support...
How to combine two images into one image in C#?
using System.Drawing;public static System.Drawing.Bitmap Combine(string[] files){ Create a list for images and read images List images = new List(); Bitmap finalImage = null; try { int width = 0; int height = 0; foreach (string image in files) { create a Bitmap from the file and add it to the list. Bitmap bitmap = new...
Location of opening of dialog boxes(window form) in C#
In my application i used some dialog boxes like about of company some customize message boxes and all that in some dialog boxes I used start position as Center parent but i forget to pass the IWin32Window Owner in show dialog as a parameter regarding that when focus is lost from my application then dialog took desktop as a parent and opens in different...
How to set image resolution and paint it in C# ?
using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Imaging; public class Form1 : System.Windows.Forms.Form { Constructor. public Form1() { InitializeComponent(); } Initialize all the...
C# Tutorial (Chapter - 1) Introduction about C# and .Net framework(1 :- .Net Plateform)
I :-.Net Plateform :-The Microsoft® .NET platform provides all of the tools and technologies thatyou need to build distributed Web applications. It exposes a languageindependent,consistent programming model across all tiers of an applicationwhile providing seamless interoperability with, and easy migration from,existing technologies. The .NET platform...
C# Tutorials
Hello to all, My next thread is about C#,In my next thread i will divide the C# thread into chapters each chapter will contain all the details about C# and .Net framework its a step by step process so go through to all the thread and please post a comment or email me at saurabhjnumca@gmail.com about this thread please give critics about this thread.If...
How to create a session manager in .Net ?
To create a SessionManager to save User objects in memory. It would be HashMap of HaspMaps.It can be used as:SessionManager MySessionManager= New SessionManager()Student S1 = New Student ("Saurabh");Student S2 = New Student ("Sandeep");Student S3 = New Student ("Deepak");//To create sessionMySessionManager.createSession(S1);MySessionManager.createSession(S2);//SAVING...
Tech-Giant(Jargons.. for Professionals): How to take Screenshot of panel,control and save it in a JPG format ?
How to take Screenshot of panel,control and save it in a JPG format ?
You can create a bitmap of screen and then save it give the stream or fileName and then dispose the object of screenshot.Bitmap theScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);theScreenShot.Save(stream_or_filename, ImageFormat.Jpeg);theScreenShot.Dispose();Another way to...
Order of Event firing in ASP.Net
Event firing order becomes critically important when you add event handling code to master pages and the content forms based on them. The following events occur when ASP.NET renders a page. I’ve listed these events in the order in which they occur.1 :-Content Page Pre Initializes2 :-Master Page Child Controls Initialize3 :-Content Page Child Controls...
Lambda Expressions in C#
Lambda expressions makes the searching life much easier.Have a look on this example :-public class TestLambdaProgram{ public static void Main( string[] args ) { List names = new List(); names.Add(“Saurabh”); names.Add("Garima"); names.Add(“Vivek”); names.Add(“Sandeep”); string stringResult = names.Find( name =>...
Basics of .Net (What is IL,CLR,CTS,CLS ?)
1: IL(Intermediate Language) :-(IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler. Microsoft Intermediate...
What are different types of JIT ?
In .net there are three type of JIT.JIT compiler is a part of the runtime execution environment.Three JIT are following :-Pre-JIT :- Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.Econo-JIT :- Econo-JIT compiles only those methods that are called at runtime....
What is Manifest in .net ?
An assembly manifest contains all the metadata.It means Assembly metadata is stored in Manifest and it needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes.Some points are given please go through it :-1:- The assembly...
How to view a Assembly of your code (What is ILDASM ?)

When it comes to understanding of internals nothing can beat ILDASM. ILDASM basically converts the whole exe or dll in to IL code. To run ILDASM you have to go to "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin". Note that i had v2.0...
How to copy the text from label in window form at run time ?
Designer view:#region DesignerViewCreate a context menu strip :this.copyPathMenuItem = new System.Windows.Forms.ToolStripMenuItem();this.labelContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.copyPathMenuItem});this.labelContextMenuStrip.Name = "labelContextMenuStrip";this.labelContextMenuStrip.Size = new System.Drawing.Size(100,...
How can I change the Border color of my control ?
public class MyButton : Button { protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); int borderWidth = 1; Color borderColor = Color.Blue; ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid,...
How to change the color of Tab Control in c#
Steps :-1. Set the TabControl's DrawMode to OwnerDraw.2. Handle the DrawItem event.private void ChangeColorOFTabControl(object sender, DrawItemEventArgs e){Font TabFont;Brush BackBrush = new SolidBrush(Color.Green); //Set background colorBrush ForeBrush = new SolidBrush(Color.Yellow);//Set foreground colorif (e.Index == this.tabControl1.SelectedIndex){TabFont...
How to set dropdown width according to longest string in C#
If you are using window control then use this method.private void AdjustWidthComboBox_DropDown(object sender, System.EventArgs e){ ComboBox senderComboBox = (ComboBox)sender; int width = senderComboBox.DropDownWidth; Graphics g = senderComboBox.CreateGraphics(); Font font = senderComboBox.Font; int vertScrollBarWidth = (senderComboBox.Items.Count>senderComboBox.MaxDropDownItems)...
How to get the file size like windows file property control ?
//Create an object of FileInfo like :- FileInfo fileObject = new FileInfo(selectedFilename);Int64 fileSize = 0;float sizeOfFile = 0fileSize = fileObject.Length;sizeOfFile = fileObject.Length;private const int FILESIZE_IN_KB = 1024;public const int FILESIZE_IN_MB = 1048576;public const int FILESIZE_IN_GB = 1073741824;public const long FILESIZE_IN_TB...
Sort ListView on column click (like windows folder detail view in xp)

Step :1 Firstly Create the object of listviewcolumn sorter class.private ListViewColumnSorter listviewColumnSorter=new ListViewColumnSorter();Step :2 Set ListViewItemSorter property of listViewlistView.ListViewItemSorter = listviewColumnSorter;Handles...
Get AssociatedFileTypes (.txt = TextDocument)
/// /// Get File Type for given file./// /// Pass the path of file/// This method returns Associated file type like :-.pdf = Adobe Acrobat Document.txt = Text Documentprivate string GetAssociatedFileType(string filePath){ private const string STRING_SPACE = " "; string extension = string.Empty; if (!string.IsNullOrEmpty(filePath))...
File System Watcher in C#(Get notified after any modification)
Drag FileSystemWatcher control in your form from toolbox and add the events for created,deletion and renaming.Ex:-#region Designer viewthis.fileSystemWatcher.EnableRaisingEvents = true;this.fileSystemWatcher.IncludeSubdirectories = true;this.fileSystemWatcher.SynchronizingObject = this;this.fileSystemWatcher.Created += new System.IO.FileSystemEventHandler(this.fileSystemWatcher_Created);this.fileSystemWatcher.Deleted...
String Functionality of C# (Play with strings)
1:- Convert string to LowerCase public static String Lower(String constantString) { return constantString.ToLower(); }2:-Convert String to UpperCase public static String Upper(String constantString) { return constantString.ToUpper(); }3:- Convert String to proper case public static String PCase(String constantString) { String strProper=constantString.Substring(0,1).ToUpper();...
Create customize OpenFileDialogBox and SaveFileDialogBox using shell
%5B1%5D.png)
The Open dialog box lets the user specify the drive, directory, and the name of a file or set of files to open.The Save As dialog box lets the user specify the drive, directory, and name of a file to save. Explorer-style Open and Save As dialog...
Get CSIDL Code (System Index of Directories)
const int CSIDL_DESKTOP = 0x0000; // const int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop)const int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programsconst int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panelconst int CSIDL_PRINTERS...
Get Information about Operating-System(Like its an English operating system or German operating system)
/// /// Get the operating system language./// public static void GetOperatingSystemLanguage(){ ManagementObjectSearcher objectSearcher = new ManagementObjectSearcher("SELECT * FROM " + "Win32_OperatingSystem"); int languageCode = 0; foreach (ManagementObject managementObject in objectSearcher.Get()) { //Create the obect of...