C# Tips
C# Tip

VS 2017 error - The command bower install exited with code 9009

4/21/2017
286 views

Problem Ran into the following error when tried to PUBLISH my ASP.NET Core web pr...

C# Tip

C# error - Cannot initialize a by-reference variable with a value

4/9/2017
407 views

C# 7.0 introduced "ref return" which allows a method to return "ref" of a value. Som...

C# Tip

How to allow HTML string in MVC

4/7/2017
164 views

In MVC, how to allow HTML string in POST action?...

C# Tip

Remove ASP.NET server info headers

1/13/2017
1097 views

Some HTTP headers sent by IIS web server disclose server information. And he...

C# Tip

Escape curly brace in string.Format()

12/19/2016
1145 views

Sometimes I make mistakes not escaping curly brace in string formatting. For example,...

C# Tip

How to change default precision and scale for decimal type in EF5

10/18/2016
1169 views

In Entity Frame 5, default precision for decimal property is (18, 2) which means prec...

C# Tip

How to convert GUID to Integer

9/21/2016
1181 views

GUID is 128 bit (16 bytes) data. To convert GUID to integer without data loss, we c...

C# Tip

Error: The "GenerateResource" task failed unexpectedly

8/3/2016
1130 views

When I tried to build a C# project, I ran into the following error. The "Generat...

C# Tip

Pass reference type using "ref"

6/27/2016
1109 views

When a reference type object is passed to another method, one can add "ref" keyword i...

C# Tip

How to restart program in C#

6/10/2016
1351 views

How do you restart the current process in C#? Well basically it is to start the...

C# Tip

Calling SQL Function from C#

6/3/2016
1163 views

A Simple example of calling a SQL function by using ADO.NET. While it is not com...

C# Tip

Tip: equivalent TSQL expression to string.IsNullOrEmpty()

5/23/2016
1124 views

In C#, we can check to see if a string is null or an empty string as follows. if...

C# Tip

Unable to find currently running process when debugging in VS

5/10/2016
1110 views

When running the following code in standalone application, it works fine. stri...

C# Tip

VS : Could not load file or assembly Microsoft.SqlServer.Management.Sdk.Sfc

3/31/2016
1585 views

Sometimes people asked some questions on one of my old blog - "VS 2012 Error : Coul...

C# Tip

foreach creates new iterator for IEnumerable

3/25/2016
1153 views

In C#, foreach statement provides a convenient way of iterating an enumerable object....

C# Tip

VS : Search Solution Explorer

3/18/2016
1110 views

One of great features in Vistual Studio... Search Solution Explorer! On top of S...

C# Tip

How to get process handle from process name in C#

2/22/2016
1776 views

A question from facebook group:How can we get process handle or process id from runni...

C# Tip

C# - Curly Braces in string.Format

2/16/2016
1102 views

I ran into an error when using the following string formatting. // Wrong var s ...

C# Tip

IIS WebSite Debugging Tip

1/22/2016
1251 views

A small note for how to debug a website (ASP.NET) hosted in remote test server. ...

C# Tip

How to check internet connectivity in C#

1/6/2016
1301 views

Since .NET 2.0, there is a method called NetworkInterface.GetIsNetworkAvailable() whi...

C# Tip

How to check the size of HTTP resource

1/5/2016
1134 views

Sometimes we want to know the size of HTTP resource before actually getting it. For e...

C# Tip

Convert long date to short date

12/3/2015
2038 views

How to convert long date string to short date strong? Let's say we got a date stri...

C# Tip

How to prevent flicker in WinForms Control

11/23/2015
1371 views

If you frequently update the content of a WinForms Control, you might observe a flick...

C# Tip

Using TLS 1.2 in C#

11/16/2015
17637 views

.NET 4.0 (or below) supports SSL 3.0 and TLS 1.0 (a successor of SSL 3.0). SSL and TL...

C# Tip

Primitive types in C#

10/28/2015
1341 views

In CLR, the primitive types are Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, I...

C# Tip

C# Multi-dimensional Array Size

10/23/2015
1461 views

When it comes to multi-dimensional array, C# supports two kinds of multi-dimensional ...

C# Tip

How to empty Recycle Bin in C#?

10/21/2015
1108 views

.NET Framework does not have handy way of emptying the Recycle Bin files. But this ta...

C# Tip

.NET Framework source code online

10/14/2015
1098 views

Someone in Facebook asked a question, 'where can I find .NET Framework source cod...

C# Tip

C# Union

10/7/2015
1149 views

In C/C++, union is a user-defined type in which all members share the same memory, bu...

C# Tip

EF Code First: How to insert master/details data

10/1/2015
1437 views

I have Order and OrderDetails table which has one to many relationship. How do I ...

C# Tip

C#: The pitfall of equality operator

9/28/2015
1093 views

I ran into equality operator (==) issue again. That is, when equality operator compar...

C# Tip

Understanding DB NULL in C#

9/23/2015
1143 views

It is not unusual for C# developer to mix DBNull up with pure "null." Tak...

C# Tip

Using Identity column in EF7 (VS 2015 ASP.NET 5)

9/21/2015
1812 views

Visual Studio 2015 (RTM) provides ASP.NET 5 Preview Template and this project templat...

C# Tip

Turkish i in C#

9/11/2015
1251 views

When comparing parameter with literal value, it is common to make it to uppercase or ...

C# Tip

Uppercase, Lowercase, Title case in C#

9/8/2015
1158 views

.NET String class has ToUpper() method which changes all characters to uppercase and ...

C# Tip

How to ping in C#

8/31/2015
1147 views

Ping is typically used to check a computer's availablity. Ping uses ICMP echo req...

C# Tip

How to change system time in C#?

8/25/2015
2546 views

In C#, DateTime struct does not have any method to set system time. How can we change...

C# Tip

C# round up issue in Math.Round()

8/24/2015
1120 views

To round up a number, C# uses a .NET method called Math.Round(). For example, Math.Ro...

C# Tip

How to wipe a file completely

8/21/2015
1126 views

We might want to wipe a file completely so that the file can never be recovered. Som...

C# Tip

How to fade in (or fade out) my form

8/18/2015
1118 views

How can I fade in and/or fade out my form (WinForms)?...

C# Tip

How to display custom string for enum value

8/5/2015
1139 views

How can we show user-defined string for enum value? For example, want to display &quo...

C# Tip

When not to use nvarchar(max)

8/3/2015
1152 views

Entity Framework has an annotation (StringLength) to set max length of string field. ...

C# Tip

C# : How to launch browser and visit web site?

8/2/2015
1142 views

In C# desktop application, how can we launch browser and navigate to a specifc web si...

C# Tip

Bug Fix: Invalid viewstate / Unable to find assembly

7/27/2015
1155 views

Bug Fix: Invalid viewstate / Unable to find assembly An exception was thrown fr...

C# Tip

When int? value is null

7/22/2015
1120 views

An interesting question: is it possible to access property or method when int? value ...

C# Tip

Bug Fix : Cannot close stream until all bytes are written

7/21/2015
2427 views

This is about a bug that I found recently. One component calling other company&#...

C# Tip

Convert byte array to hex string

7/17/2015
1132 views

Sometimes we need to convert byte array to a concatenated hex string. Nice thing abou...

C# Tip

How to get unix timestamp in C#

7/13/2015
1133 views

The unix time stamp is the number of seconds between a particular date and the Unix E...

C# Tip

How to hide form when button is clicked

7/7/2015
1109 views

I want to capture the entire screen from my winform application. I have a button ...

C# Tip

Finding element index of a list using LINQ

7/6/2015
1143 views

One interesting way of finding an element index of a list using LINQ. Enumerable...

C# Tip

Ambiguous method overloading - string vs string[] args

7/1/2015
1142 views

A question from a Facebook C# group. How can we get around the ambiguous method o...

C# Tip

Integer division to get decimal result

6/28/2015
1114 views

Sometimes Web API can return money data as an integer. For example, Stripe API (f...