My Thoughts & Views

Archive for the ‘C#’ Category

Difference Between Interface and Abstract Class

Posted by: intelbot on: August 17, 2009

Interfaces –contain only abstract methods –interface can’t be inherited from a class –using interfaces we can achieve multiple inheritance –doesn’t allow accessibility modifiers (Public/Private/Internal) –can’t contain fields, constructors –is must implementable & its scope is upto any level of its inheritence chain. Abstract Class –contain both abstract methods as well as concrete methods –can extend [...]

Steps: 1. Add wnvhtmlconvert.dll to Project Reference under Visual Studio 2. Import it into your code behind file “using Winnovative.WnvHtmlConvert;” 3. Add your PdfConverterKey into Web.Config <add key=”PdfConverterKey” value=”your key here”/> 4. Write Below Code (Click to Expand) And you are done. Let me know if you have any questions

Converting Enum to List

Posted by: intelbot on: May 5, 2009

Method : Usage :

I need to write comments for the below code, bcoz of lack of time i am posting only abstract things,if you want to know something, write comment, i will reply. HTML login control < input type=”text” name=”txtUserName” id=”txtUserName” class=”textBoxes” /> jQuery Rule: Add the below rule into script tag in header & add reference to [...]

Interface Inheritance Naming Conflicts

Posted by: intelbot on: March 25, 2009

Suppose you have two interfaces, lets say Interface-IA, Interface-IB & in both you have declared Name as a property as follows. public interface IA { string Name { get; set; } String Adress { get; set; } } public interface IB { string Name { get; set; } } Now, you write an interface -IC [...]

C# Code for measuring application performance

Posted by: intelbot on: March 24, 2008

The DateTime class is not very exact and only can measure in milliseconds. When doing performance measuring on an application you most certainly need to be able to measure with smaller time units than that. High-resolution timers are supported in the Win32 API so following code wraps it up in a simple class: public class [...]

Calculate the sum of a column in a dataset

Posted by: intelbot on: February 5, 2008

Problem : Calculate the sum of a column in a dataset Solution :After filling the dataset from your query you can calculate the sum of a numeric column. Dataset’s DataTable provides a default method called Compute through which you can perform any aggregate function based operation on columns in a DataTable. Suppose you have 1. [...]

Function to Reverse a String in C#

Posted by: intelbot on: January 14, 2008

public static String Reverse(String strParam) { if(strParam.Length==1) { return strParam; } else { return Reverse(strParam.Substring(1)) + strParam.Substring(0,1); } }

C# : Interview Questions

Posted by: intelbot on: December 5, 2007

This is second in series of Interview Questions for .NET Application developer position. C# * Does C# supports multiple inheritence?* What is a delegate?* What are setallite assemblies?* Differences between Namespace, Class, Assembly?* What is the difference between managed and unmanaged code?* What is serialization?* What’s a bubbled event?* What is garbage collection? How dot [...]

C# and Sorting Algorithms : Bubble Sort

Posted by: intelbot on: November 26, 2007

– It is slowest sorting algorithm in use– It is considered as Most In efficient Sorting Algorithm. How it works? The basic idea is to compare two neighboring objects, and to swap them if they are in the wrong order. This process is repeated until it completly sorts the list. This causes larger values to [...]

C# and Sorting Algorithms : Introduction

Posted by: intelbot on: November 26, 2007

In Computing, a fundamental problem related to lists is Sorting (or Ordering) them in Ascending or Descending. In this series i would like to explore the Sorting Algorithms from C# point of View. Following is the list of Commnon Sorting Algorithms in use Bubble Sort Insertion Sort Selection Sort Quick Sort Shell Sort Heap Sort [...]

Singleton Class in C#

Posted by: intelbot on: September 13, 2007

1 public sealed class SingletonClass 2 { 3 private SingletonClass() 4 { 5 } 6 7 private static SingletonClass instance = new SingletonClass(); 8 9 public static SingletonClass Instance 10 {11 get 12 { 13 if(instance == null) 14 {15 instance = new SingletonClass();16 return instance;17 } 18 else 19 return instance; 20 } 21 [...]

Dynamically removing dynamically added controls

Posted by: intelbot on: April 11, 2007

I dynamically add controls to my form, and also i need the option to remove them again.So first i did this to remove,(as per my logic) foreach(Control contrl in this.Controls){ if (contrl .GetType() == typeof(TextBox)) { this.Controls.Remove(contrl ); }} But this code removed only alternative textboxes. At first i was unable to find it out,but [...]

Funtion to Find whether the String is Palindrome or Not

Posted by: intelbot on: March 27, 2007

using System; class test{ private static void Main() { Console.WriteLine(“Is ‘ada’ Palindrome : {0}”,IsPalindrome(“ada”)); Console.ReadLine(); } public static bool IsPalindrome(String strParam) { int iLength,iHalfLength; iLength = strParam.Length – 1; iHalfLength = iLength/2; for(int iIndex=0;iIndex<=iHalfLength;iIndex++) { if(strParam.Substring(iIndex,1)!=strParam.Substring(iLength – iIndex,1)) { return false; } } return true; }}

Detect OS Version Using C#

Posted by: intelbot on: March 27, 2007

// Get the Operating System From Environment ClassOperatingSystem os = Environment.OSVersion; // Get the version information Version vs = os.Version; MessageBox.Show (vs.Major.ToString()); // vs.Major;//vs.Minor;//vs.Revision;//vs.Build;

Adding Errors to Event Log

Posted by: intelbot on: March 27, 2007

using System.Diagnostics; private void AddLog(string sErrSource, string sErrMessage, EventLogEntryType ErrType){ EventLog objLog = new EventLog(“AppLog”); objLog.Source=sErrSource; objLog.WriteEntry(sErrMessage,ErrType);} This function will create an event log called “AppLog” and adds the source and message into that. EventLogEntryType enum contains 1. Error 2. FailureAudit 3. Information 4. SuccessAudit 5. Warning


Follow

Get every new post delivered to your Inbox.