Convert Json to Classes




If you don't want to waste your time to write classes to Deserialize json string , this tools should help you to save your time

1. Json formatter

Every web developer has the problem to read JSON string so this tool should solve the problem.

2. Jsonutils

 the best Tool to convert JSON to C# , Java, SQL tables, PHP , vb.net Classes.

3. Json2csharp

this online tool to Convert JSON to C# Classes.

4. Visual Studio Trick

Copy JSON string and from Visual Studio Click on Edit -> paste special -> Parse JSON As Classes.

5. Realmgenerator

online tool to convert JSON to Objective-c, Swift Classes.

Use StringBuilder or string class for concatenating strings





when you want to concatenate strings you'll think about performance so,
Is StringBuilder faster than strings when concatenating or not ?



StringBuilder is the best performance for a concatenation if an arbitrary number of strings are concatenated, however,  the String class is preferable for a concatenation operation if a fixed number of Strings are concatenated.

Note :
You also need to keep in mind that a new string is created at each concatenation when standard string
concatenation is used.so, think about the number of objects that will be created in memory so,
 This can lead to an explosion of objects for the garbage collector to deal with.

when compile Cordova project got Error Clear Cordova







When compile Cordova project got this error :

Please Go to Tools --> Options --> Tools for Apache Cordova --> Cordova Tools --> Clear Cordova.



Solution :

open command line as Administrator

then  write
npm install -g "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\packages\vs-tac".


If you get :

{"node":">=0.6","npm":"1"} (current: {"node":"5.1.0","npm":"3.1.12"

Then write Npm install –g npm

How to Check if Request come from ajax in asp .net MVC



To Check if Request comes from ajax in Controller use the following :

public JsonResult GetEmployeeName( int id)
{
     if (Request.IsAjaxRequest())
      {
        
       }
}

or you can set [AjaxOnly] annotation to set action in controller works only for ajax
request.



[AjaxOnly]
public JsonResult GetEmployeeNameint id)
{
var result = Json(GetEmployeeByID(id)
, JsonRequestBehavior.AllowGet);
return result ;
}

Change Datagridview Odd and even rows color C#





You can change Datagridview odd and even rows color by adding this code
C#:

  foreach (DataGridViewRow row in dataGridView1.Rows)
  {
            if (row.Index % 2==0 )
            {
                row.DefaultCellStyle.BackColor = Color.Green;    
            }
            else
             {
                row.DefaultCellStyle.BackColor = Color.LimeGreen;
              }

   }


or you can use AlternatingRowsDefaultCellStyle from designer

or by code :


dataGridView1.RowsDefaultCellStyle.BackColor = Color.Green;

   dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LimeGreen;




Featured Post

Convert Json to Classes

Followers