Thursday 13 April 2017

The Periodic Table Of SEO Success Factors


Visual studio shortcuts to improve your productivity

There are some useful shortcuts to improve your productivity while writing a code.

1) Format scattered and unaligned code

     CTRL + K + D


2) Comment code

     CTRL + K + C


3) Uncomment code

     CTRL + K + U

Tuesday 11 April 2017

Standard Naming Convention for ASP.NET and C#

For any programming language standard naming system is very import. It makes a complex system easy for others.Use these in your own projects and/or adjust these to your own needs.

There are different types of naming casing style. First let’s understand different types of casing styles.

Camel Case (camelCase): First letter of the word is lower case and then each first letter of the part of the word is upper case. Example: numberOfDays

Pascal Case (PascalCase): First letter of the word is upper case and then each first letter of the part of the word is upper case. Example: DataTable

Underscode Prefix (_underscore): The word begins with underscore singe and for the rest of the word use camelCase rule. Example: _strFirstName

Hungarian Notation: First letter of the word is about its data type and rest of the word is camelCase. Example: iStudentNumber (i=integer)


Uppercase: All letters of the word are uppercase. Example: ID, PI

How to write log file in c#?

Below is the function to create text log file in C#

public static void WriteLog(string strLog)
    {
        StreamWriter log;
        FileStream fileStream = null;
        DirectoryInfo logDirInfo = null;
        FileInfo logFileInfo;

        string logFilePath = "C:\\Logs\\";
        logFilePath = logFilePath + "Log-" + System.DateTime.Today.ToString("MM-dd-yyyy") + "." + "txt";          
        logFileInfo = new FileInfo(logFilePath);
        logDirInfo = new DirectoryInfo(logFileInfo.DirectoryName);
        if (!logDirInfo.Exists) logDirInfo.Create();
        if (!logFileInfo.Exists)
        {
            fileStream = logFileInfo.Create();
        }
        else
        {
            fileStream = new FileStream(logFilePath, FileMode.Append);
        }
        log = new StreamWriter(fileStream);
        log.WriteLine(strLog);
        log.Close();
    }