admin, Author at Coding Sharp

Author: admin

Site Admin is a writer of http://www.codingsharp.com website. He is a software professional with hands on 4+ years of experience. Generally he writes an article about Javascript, SQL Server and JQuery. Here he shares his notes, experiences, examples.
Explore the Use of System.Environment Class

Explore the Use of System.Environment Class

Asp.Net, Asp.Net MVC, C# Interview, C#.Net
System.Environment class can not be inherited. It provides valuable information about current platform and environment of the system. It uses to retrieve environment variable settings, version of the CLR and call stack contents etc. It has various methods and property to get the useful information about current working environment. Lets have a look on some of most used properties. Get the Machine Name - To Get the current system's machine name we can use MachineName property of Environment class. For example : Console.WriteLine("Machine Name :" + Environment.MachineName); Get the Current Working Directory - To Get the current working directory we can use CurrentDirectory property of Environment class. For example : Console.WriteLine("Current Directory :" + Environme...
What is the Difference between Build, Rebuild and Clean in Visual Studio?

What is the Difference between Build, Rebuild and Clean in Visual Studio?

Asp.Net, Asp.Net MVC, C# Interview, C#.Net, Difference
If you are a Microsoft Asp.Net Developer then usually you came across this words like Build, Rebuild and Clean. This article gives you explanation about Difference between Build, Rebuild and Clean If you are using Visual studio you might have question that what is difference between Build, Rebuild and Clean ? here we are going to understand the diversity between them. Build Solution : When we build any solution then Visual studio will build/compile all assemblies (Dlls and EXE's) that are changed, it is basically incremental or partial process in which only CHANGED assemblies are compiled if there is no changed assemblies it won't get build Rebuild Solution: It is full compiled case, in which all assemblies (either changed or not) are deleted and recompiled again, irrespect...
Difference between .Net DLL and Normal DLL file

Difference between .Net DLL and Normal DLL file

Asp.Net, Asp.Net MVC, C# Interview, C#.Net, Difference
DLL is stands for Dynamic Link Library. DLL is a file format which holds multiple codes and procedures for windows applications. Generally DLL files are created so that multiple application can use it at the same time. It has common code which may be used by multiple programs so it can reduce the disk space, load faster and consume less memory. DLLs can be converted to static libraries by using MSIL (Microsoft Intermediate Language) diassempler. It is very similar to .EXE file but it can not be execute directly like EXE, but holds same information like code, data and resources. What is .NET dll file? When we create a .NET DLL or Assemply in .Net Languages like VB.Net or C#.Net it will create a Managed Assembly. Managed Assembly is the component standard specified by Microsoft .Net. S...
What are the Differences between the Debug class and Trace class?

What are the Differences between the Debug class and Trace class?

Asp.Net, Asp.Net MVC, C# Interview, C#.Net, Difference
Debug and Trace both classes are included in Systems.Diagnostics namespace and have very similar methods. The main difference is that call to Debug class is included in Debug mode only while call to Trace class will be included in Debug as well as Release mode also. So in short we can say it is advisable to use Debug at the time of application development, while Trace option is used at the time of application deployment, like we can trace any error and write it into log files etc. What is the differences between a Debug and Release build? When we are building any .Net project there are two configuration we can select 1 is Debug and another is for Release, While we are developing an application default mode is Debug and programmers keeps is Debug mode for debugging code step by ste...
C# interview question answers

C# interview question answers

C# Interview
Q-1: Which of the following statement is true? a. try block must be followed by catch and finally block both. b. try block must be followed by catch or finally block or both. c. try block cannot include another try block. d. All of the above. Correct Answer: (b) try block must be followed by catch or finally block or both. Q-2: Which of the following datatype can be used with enum? a. Int b. String c. Boolean 4. All of the above Correct Answer: (a) Int Q-3: A partial class allows ________ a. Implementation of single class in multiple .cs files. b. Declaration of multiple classes in a single .cs file. c. Implementation of multiple interfaces to single class. d. Multiple class inheritance. Correct Answer: (a) Implementation of single class in multiple .cs files. ...
XmlDocument class

XmlDocument class

Asp.Net, C#.Net
In the previous article we have seen how to write an XML file using XmlWriter class, in this article we will see how to write an XML file using XmlDocument class. Both are writing the XML file only, however when we want to update an existing XML file then XmlDocument class will be easy to use. Because XmlWriter class will use higher memory consumption. Now look at the below sample code Above code will produce below output As we can see, first we have created an object of XmlDocument class. It will be used to create new element and new attribute both using the CreateElement() and CreateAttribute() methods. Each time we will do the same process, what I mean here is if we want to create 3 nodes in the root element developers then we will do use document object 3 times to cre...
Writing XML with the XmlWriter class

Writing XML with the XmlWriter class

Asp.Net, C#.Net
In previous article we have see about writing and reading text document, but now it's time to start dealing with XML file. Anyhow XML is just a plain text, we can simply start writing an XML tags to the file and save it with .xml file extension. But for .net framework it is very easy and safe to handle. For writing an XML file .net framework provides two different options. XMLWriter and XmlDocument, we will see XMLDocument in the next article. In this article we will focus on XMLWriter approach Let's see the basic different between XmlWriter and XmlDocument. XMLWriter uses less memory compare to XmlDocument, that is the only 1 issue if we are writing a vey big file. Another difference is if we are modofing an xml file using XmlDocument, we can read an exisitng file, change it as req...
StreamReader

StreamReader

Asp.Net, C#.Net
StreamReader class In my previous article we have have seen how to read from text file using File class and how to write into text file using StreamWriter class. In this article we will see how to read from text file using StreamReader  class. Using Statements: It is recommended to use using statements while we are using StreamReader class, which ensures that is is removed from the memory once it is no longer needed. The syntax is very easy to use. StreamReader class reads text file, it is available in System.IO namespace. It provides very good performance. Using StreamReader we can read a file synchronously and asynchronously, we need to provide a relative or absolute path to the file. Lets check with the example that how to synchronously read a line from text file using StreamR...
Understanding StreamWriter class

Understanding StreamWriter class

Asp.Net, C#.Net
We have seen how to write in text file using File class in our previous article. Today we will see how to use StreamWriter class to write in a text file. This class is very helpful to write text data into files. This class contains method to write to a file synchronously like Write and WriteLine or asynchronously WriteAsync and WriteLineAsync. Using Statements. It is recommended to use using statements while we are using Stream Writer class, which ensures that is is removed from the memory once it is no longer needed. The syntax is very easy to use. Lets check with the example that how to synchronously write to a text file using Stream Writer class. First we need to declare and initialize an instance of the class with using statement. It is available is available in System.IO namespace...
How to Read from a Text File using C#

How to Read from a Text File using C#

Asp.Net, C#.Net
In previous article we have see "How to write to a Text File using C#", Now in this article we are going to learn how can we read text file using C#. In most of the application either we are writing something to text file or reading from text file. Reading from and writing to text file is essential for major application. So lets see the code for reading text file using C#. The main important class is File for Read from text file which exists in System.IO namespace. So first we need to import System.IO namespace to our project. Now lets see example for ReadAllText method ReadAllText ReadAllText method will read all the content of a given file. It will take 1 parameter as a full file path. Example #1 ReadAllLines ReadAllLines method will read all the lines of a give...