CSharp examples for System.Runtime.Serialization.Json:Json
Get string of JSON array.
using System.Text; using System.Linq; using System.Collections.Generic; using System;// www .ja v a 2 s . c om public class Main{ /// <summary>Get string of JSON array.</summary> public static string GetJsonArray(this string[] items) { if(items != null) { var sb1 = new StringBuilder(); for(int i = 0;i < items.Length;i += 1) { sb1.AppendFormat(", \"{0}\"", items[i]); } return String.Concat("[", sb1.ToString().Substring(2), "]"); } return String.Empty; } /// <summary>Converts the value of the specified object to its equivalent string representation.</summary> /// <returns>The string representation of value, or System.String.Empty if value is null.</returns> public static string ToString(Object value, string defaultValue) { if(value != null) { var s = Convert.ToString(value); if(!String.IsNullOrEmpty(s)) { return s; } } return defaultValue; } }