Posts

Showing posts with the label C#

Convert Viewmodel to JSON string using C#, convert json string to JSON Format using C#

//CONVERT POST PARAMETERS INTO JSON-SERIALIZE var json = JsonConvert.SerializeObject(model); // Convert Json String to JSON Format in C# dynamic responseData = Newtonsoft.Json.Linq.JObject.Parse(_responseData);

Accessed JArray values with invalid key value. Array position index expected

Accessed JArray values with invalid key value: “fields”. Array position index expected  ========================================================== { "response" :{ "status" : "ok" , "userTier" : "approved" , "total" : 1 , "startIndex" : 1 , "pageSize" : 10 , "currentPage" : 1 , "pages" : 1 , "orderBy" : "newest" , "results" :[{ "id" : "sustainable-business/sustainable-finance-where-next-open-thread" , "sectionId" : "sustainable-business" , "sectionName" : "Guardian Sustainable Business" , "webPublicationDate" : "2014-02-13T13:27:00Z" , "webTitle" : "Where next for sustainable finance? - open thread" , "webUrl" : "http://www.theguardian.com/sustainable-busi...

convert string to MD5 hash C#

public static string MD5Hash ( string input ) { StringBuilder hash = new StringBuilder (); MD5CryptoServiceProvider md5provider = new MD5CryptoServiceProvider (); byte [] bytes = md5provider . ComputeHash ( new UTF8Encoding (). GetBytes ( input )); for ( int i = 0 ; i < bytes . Length ; i ++) { hash . Append ( bytes [ i ]. ToString ( "x2" )); } return hash . ToString (); }

how to Replace null value with 0 Using C#

how to Replace null value with 0 Using C# //here we suppose that objDataTable have data collection as table now access this //datatable object. decimal  j = 0;  j = objDataTable.Rows[0]["Qty"] ==  DBNull .Value ? 0 :  Convert .ToDecimal(objDataTable.Rows[0]["Qty"]); NOTE :- //if   DBNull.value is null  then   "0 " else  "your code here")  // ? = then // : = else Thank You [Sumit Singh Shekhawat]

Calculate simple interst using c sharp in console application

Image
How to calculate SI (Simple Interest) using C# in Console Application _____________________ start _________________________ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Oops_Concepts {     class Program     {         static void Main()         {             Program objProgram = new Program();             objProgram.GetSimpleInterest();             Console.Read();               }          public void GetSimpleInterest()         {             double principle, interst = 0;             int time = 0;                          Console.Write("Enter Principle Am...

Insert Data in Database (mssql)

Image
How TO Insert Data In MSsql DataBase with ASP.NET (C#). So let's Start Now...  You must do 5 steps for insert, update, and delete (DML)Operations. Step 1: Add " using System.Data.SqlClient ; ". Step 2: Create Object of SqlConnection...  like this..  ( SqlConnection Objname = new SqlConnection(); ) Step 3: Crate Object of SqlCommand.... like this... ( SqlCommand  cmd = new SqlCommannd(); ). Step 4: After create Objects of sqlconnection and sqlcommand You Open the Connection. Like this (Objname.Open() ;) Step 5: Execute your Query... Here Example::::...... -------------------------------------------------------------------------------------------                                                                   Code Start ------------------------------------------------------------------...