C#

Create windows service setup in visual studio

Windows service can be setup by using DOS command but that is not so easy especially for those people who are not technically strong, some time we create windows service for our client and the want a setup file so they simply click on the setup file and follow the instruction. So we will see how to create a windows service setup with Visual Studio. To learn how to create windows service see my... By Ali Adravi   On 11 May 2013  Viewed: 1,042
  • windows service
  • c#
  • setup

How to create windows service in C# visual studio 2010

Creating windows service in C# is really easy but when we need to create first time we face many problems so in this post we will try to learn everything about window service. In this article we will create a windows service which will run after a particular interval, and time should be configurable and code to write log in a text file as well as send email if there is any error to execute the... By Ali Adravi   On 30 Apr 2013  Viewed: 6,742
  • c#
  • windows service

Overloading and Overriding in C# with example

In my early day career in many interviews I asked same question, what is overloading and overriding so decided to write this small article which may help someone. We will see here in detail about the overloading, overriding and then differences between them. --- **Overloading:** --- is the mechanism to have more than one method with same name but with different signature (parameters). A... By Hamden   On 31 Mar 2013  Viewed: 24,618
  • overloading
  • c#
  • oops

IEnumerable and IEnumerator in C# with real time example

We will discuss here what is IEnumerable, IEnumerator, what are differences between them, where should we use IEnumerable and where to IEnumerator, once we will finish our discussion it will be clear, which one would be best for which situation and why, so let’s see it with example To better understand we will create a list of age List<int> ages = new List<int>(); ages.Add(10); ... By Ali Adravi   On 29 Mar 2013  Viewed: 29,659
  • oops
  • c#

Covariance and Contravariance in C# 4.0 with example

C# the language, right from the very beginning is always supported covariance and contravariance but in most simple scenario, now in C# 4.0 we have full support of covariance and contravariance in all circumstances, generic interface and generic delegates, other C# types already support from first version of C#. These two terms sounds like technically scary as we will see they are incredibly... By Ali Adravi   On 29 Mar 2013  Viewed: 3,467
  • c#
  • oops

default value for different data type in C#

In C# there are different data type and they use some default value when we declare a variable. When we define a variable of type int or Int32 say int score; so what is the value of score, will it be null or zero, in the same way if we create a variable of type string/String what value it holds by default. I was working on a project and used following code int score; If... By Ali Adravi   On 27 Mar 2013  Viewed: 1,136
  • c#

enum in C# and conversion

An enumeration type (also known an enumeration or an enum) provides an efficient way to define a set of named integral constants that may be assigned to a variable to make programming clear, understandable and manageable. There are ways of using, like how to use enum in switch and case statement, how to convert a text to enum or number to enum to compare, we will discuss here all these points in... By Hamden   On 27 Mar 2013  Viewed: 1,861
  • c#
  • oops

Dynamic vs var in C# with example

When we have var which dynamically holds any type or value so why we need dynamic type, what are the differences and situations where we can use dynamic rather than var, there were some question in my mind so I explored more which I want to share here. There are two things, static type and strong type checking, with static type checking the compiler will produce an error for any call that... By Nathan Armour   On 26 Mar 2013  Viewed: 1,610
  • c#
  • oops

Array in C# - single, multiple and jagged array

An array can be initialized in several ways, it can store a single value or series of values, every element must be set of same type, C# supports single-dimensional arrays, multidimensional arrays (also call rectangular array) and array-of-arrays (referred jagged arrays), let’s discuss features of array in C# like how to declare array in C#, How to initialize values to an array, how to define the... By Ali Adravi   On 24 Mar 2013  Viewed: 1,651
  • c#
  • array
  • asp.net

XmlDocument Vs XDocument and their usage

When there was XmlDocument why we need XDocument, is there any better feature available with XDocument, answer is yes, XDocument has a number of benefits, easy to create, easy to update, easy to search, ability to use LINQ to XML, cleaner object model etc. In this post we will see some examples and difference of code while using XmlDocument and XDocument; we will discuss some way to convert... By Ali Adravi   On 16 Mar 2013  Viewed: 801
  • xml
  • asp.net
  • c#

Code Snippets and short cuts

What is code snippets? Code snippets are small blocks of reusable code that can be inserted in a code file using a combination of hotkeys. It help us to speed up to type the code by using some initial characters and tab key complete the rest for us. Here is the list of some useful and available snippets Try Catch: type **try** and press Tab try { } catch... By Ali Adravi   On 16 Jan 2013  Viewed: 318
  • c#

Add facebook twitter and google plus in C# MVC application

You need to share your website content with faceboo, twitter and google+ to increase traffic of your website. it's quite easy to implement. You need just a helper class and one line code in your page to call that helper class and done. so let's first write the helper class public static class SocialNetworkingHelper { #region[Twitter helper Method] private... By Ali Adravi   On 13 Jan 2013  Viewed: 2,821
  • mvc
  • c#

Log error in a text file in ASP.Net

It’s good practice to log all the error into a file or database so in future you can check, how your application is working, and is there any issue which is not caught by Q.A. team. Really it's helpful to understand and caught the issues after deploying the application on production server. Create a method to log the error into a file: public void LogError(Exception ex, String... By Myghty   On 30 Dec 2012  Viewed: 774
  • asp.net
  • c#

Boxing and Unboxing in C#

We know that C# data types are divided into two types, value type and reference type 1. Value types, which are allocated on the stack and 2. Reference types, which are allocated on the heap How does this square with the ability to call methods on an int, which is a value on the stack? The way C# achieves this is through a bit of magic called boxing. Boxing and its counterpart... By Ali Adravi   On 27 Dec 2012  Viewed: 751
  • c#
  • oops

Optional Parameters and Named Parameters In C# 4.0

A long-requested feature for C# was to allow for method parameters to be optional. Two closely related features in C# 4.0 fulfill this role and enable us to either omit arguments that have a defined default value when calling a method(optional parameter), and to pass arguments by name rather than position when calling a method(named arguments). The main benefit of these features is to improve... By Alicia Gonzalez   On 27 Jun 2012  Viewed: 663
  • c#
12