Refinance now before rates go up! Get multiple rate quotes at GetMyLender.com.
Showing posts with label C Sharp. Show all posts
Showing posts with label C Sharp. Show all posts

C# Reflection Examples

C# Reflection Examples

Reflection Examples [C#]

This example shows how to dynamically load assembly, how to create object instance, how to invoke method or how to get and set property value.

Create instance from assembly that is in your project References

The following examples create instances of DateTime class from the System assembly.

ASP.NET Webdomain Recycles Automatically on Deletion of Sub-directory

While working on a web application, once upon a time I was presented some weird behavior on ASP.NET.

In ASP.Net web application, When you delete a directory the session gets expired automatically. This is one of the frustrating error. It is the default nature if you are deleting a sub-directory within your application, your app domain will restart. This removes all session data.

Following observations will help you to find base of this issue:
- Session times out randomly while working on the application.

How to Maintain Session in ASP.NET application after deletion of subdirectory

In ASP.Net web application, When you delete a directory the session gets expired automatically. This is one of the frustrating error. It is the default nature if you are deleting a subdirectory within your application, your app domain will restart. This removes all session data.

Why the asp.net worker process recycles which kills all the session variables in memory is due to dynamically deleting a folder under the root application folder.
ASP.NET runs a File Monitor (FCN) that observes any change to the structure of the Virtual Directory. In case of any change the application is recycled.

Minify CSS and JS file using Visual Studio 2012

Before going on our main topic we have to discuss about one of the Dot Net feature i.e. Microsoft’s Web Optimization Framework. So, what is Web Optimization Framework and how to use this framework in Asp.net web form application? Microsoft’s (ASP.NET) Web Optimization Framework introduces a way to bundle and optimize CSS and JavaScript files.

If anyone wants to install Microsoft ASP.NET Web Optimization Framework, run the following command in the Package Manager Console of Visual Studio 2012.

C-Sharp Code to Check if Internet Connection is Available or Not

In some of our applications it is necessary to connect to Internet. So before connecting to Internet it is necessary to check, whether your application has Internet access.

May be you are thinking to solve this problem just by ping -ing to google.com or any websites. Yes this will work in most of the cases, and it is also a simple, good and important method. But as an Application developer it is not the best method to do that.

Difference between GET and POST Methods

In this article, we will discuss about difference between GET and POST Methods. So that it will usefull in your apllications.

GET Method ():

1) Data is appended to the URL.
2) Data is not secret.
3) It is a single call system.
4) Maximum data that can be sent is 256.

Difference between Library and Framework

A Library and a Framework are a set of classes, modules and/or code (depending on the programming language) that can be used in your applications.

Suppose you have to maintain log or debugging info in your applications, draw charts, create an specific file formats like .html, .pdf, .xls, connect to a data base, create applications using Design Patterns or simply create some/complete application etc.

These types of problems can be solved using Framework or a Library.

What is the Difference between Ref and Out in c sharp with Examples

In this post we will learn about ref and out parameters in c# with examples. While looking forward, we have to know about ref and out parameters and how we can use it and where to use ? Both ref and out parameters are used to pass as an arguments to a method. Actually method can return zero or one value, so these parameters are very helpful whenever methods want to return more than one value.

So, what is the main difference between these both parameters?

Both parameters used for same purpose but ref parameter need to initialize it before passing to the method and out parameter you don’t need to initialize before passing to function. Here we will go in more detail by using examples.

How to Increase Performance of Stored Procedures

When we fire SQL for the first time, three things happen:

• The SQL syntax is checked for any errors.
• The best plan is selected to execute the SQL (choice to use clustered index, non-clustered etc.).
• Finally the SQL is executed.

As in one of the article Mr. Shivprasad koirala says that Stored Procedures Do Not increase performance. Performance of inline parameterized SQL is the same as that of Stored Procedures. They had also proved why Stored procedure to be used.

Regular Expression in Dot Net Framework Part I - Character Escapes and Character Classes

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.

Each section in this quick reference lists a particular category of characters, operators, and constructs that you can use to define regular expressions:

Regular Expression in Dot Net Framework Part V - Regular Expression Options and Miscellaneous Constructs

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Regular Expression Options

You can specify options that control how the regular expression engine interprets a regular expression pattern. Many of these options can be specified either inline (in the regular expression pattern) or as one or more RegexOptions constants.

Regular Expression in Dot Net Framework Part IV - Alternation Constructs and Substitutions

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Alternation Constructs

Alternation constructs modify a regular expression to enable either/or matching. These constructs include the language elements listed in the following table.

Regular Expression in Dot Net Framework Part II - Anchors Grouping and Constructs

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Anchors

Anchors, or atomic zero-width assertions, cause a match to succeed or fail depending on the current position in the string, but they do not cause the engine to advance through the string or consume characters. The metacharacters listed in the following table are anchors.

Regular-Expression-in-Dot-Net-Framework-Part-III-Quantifiers-and-Backreference-Constructs

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Quantifiers

A quantifier specifies how many instances of the previous element (which can be a character, a group, or a character class) must be present in the input string for a match to occur. Quantifiers include the language elements listed in the following table.

What is AutoEventWireup attribute and its use in ASP.NET ?

AutoEventWireup attribute in ASP.NET

AutoEventWireup is an attribute of the @ Page directive. The AutoEventWireup attribute may have a value of true or false. The value is set to false when you create a new ASP.NET Web Application.

This article describes what is AutoEventWireup attribute and its use in ASP.NET. This article also describes some of the options of this attribute by using coding and examples of the ASP.NET Web Forms code that is written in Microsoft Visual C# .NET.

You can specify a default value of the AutoEventWireup attribute in several places:
1) The Machine.config file
2) The Web.config file
3) Individual ASP.NET Web Forms (.aspx files)
4) Web User Controls (.ascx files)

Difference between Python and other programming languages (C, C++, JAVA, .NET)

In this section I have brief describe the difference between the python and other programming language. This comparison is based on language issue; practically the choice of language is depend on other real fact e.g. Cost, training, availability, even emotional attachment.

Programming language classified in three ways,

Low level: This type of language is directly access the memory and hardware, the language come Under this category are Assembly, C, C++. These are requiring more detail orientation.

Manage: This category include Java, C# they featured that you scarifies for your need like memory management, organization, because they are not directly access the hardware and memory the problem of platform dependency is resolve. But these tools high configure machine because while your application running these tool also load.

Interpreted: This include Python, JavaScript, Html 5 with large library as your need and it provides Powerful feature tools such as web browser and string manipulation libraries. It require very less organization and organization skills.

Difference between Int32.Parse(), Convert.ToInt32() and Int32.TryParse() in C#

In this article, we will discuss what are the differences between Int32.Parse(), Convert.ToInt32() and Int32.TryParse() in C# and when and which will be useful in programs.

As you are already known about int in C#. It is used to hold integer value in memory which represents a 32-bit signed integer. While coding many times you come across int, Int16, Int32, Int64. int and Int32 are likely to be same.
All these are stuct type means value type/premetive type.
int => System.Int32 and Represents a 32-bit sigened integer.
Int16 => System.Int16 and Represents a 16-bit sigened integer.
Int32 => System.Int32 and Represents a 32-bit sigened integer.
Int64 => System.Int64 and Represents a 64-bit sigened integer.

Singleton Pattern In C Sharp

What is Singleton Pattern ?

Singleton pattern is one of the simplest design patterns. This pattern ensures that a class has only one instance and provides a global point of access to it.

History of Design Patterns :

Singleton pattern falls under Creational Pattern of Gang of Four (GOF) Design Patterns in .Net.

In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book (Design Patterns : Elements of Reusable Object-Oriented Software) for explaining the concept of Design Pattern in Software development. These four authors are collectively known as Gang of Four (GOF).

The 23 Design patterns are defined by the Gang of Four programmers. These 23 patterns are divided into three groups depending on the nature of the design problem they intend to solve.

Groups are 1) Creational Design Patterns 2) Structural Design Patterns 3) Behavioral Design Patterns.

Out of these three groups, singleton is the Creational Design Patterns.