Format:
Recent snippets matching tags of format
static void Main(string[] args) { Console.WriteLine(PhoneNumber("12345678901234")); Console.WriteLine(PhoneNumber("1234567890123")); Console.WriteLine(PhoneNumber("123456789012")); Console.WriteLine(PhoneNumber("12345678901")); Console.WriteLine(PhoneNumber("1234567890")); Console.WriteLine(PhoneNumber("123456789")); Console.WriteLine(PhoneNumber("12345678")); Console.WriteLine(PhoneNumber("1234567"));
71 Views
no comments
string strFormatedGuid = Guid.NewGuid().ToString("N"); //Where N is the format, can be any of the ones described below /* Format: N Output 32 digits: 00000000000000000000000000000000 Format: D Output 32 digits separated by hyphens: 00000000-0000-0000-0000-000000000000
70 Views
no comments
// create date time 2008-03-09 16:05:07.123 DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123); String.Format("{0:y yy yyy yyyy}", dt); // "8 08 008 2008" year String.Format("{0:M MM MMM MMMM}", dt); // "3 03 Mar March" month String.Format("{0:d dd ddd dddd}", dt); // "9 09 Sun Sunday" day String.Format("{0:h hh H HH}", dt); // "4 04 16 16" hour 12/24 String.Format("{0:m mm}", dt); // "5 05" minute String.Format("{0:s ss}", dt); // "7 07" second String.Format("{0:f ff fff ffff}", dt); // "1 12 123 1230" sec.fraction
69 Views
no comments
// Just two decimal places String.Format("{0:0.00}", 123.4567); // "123.46" String.Format("{0:0.00}", 123.4); // "123.40" String.Format("{0:0.00}", 123.0); // "123.00" // Max. two decimal places String.Format("{0:0.##}", 123.4567); // "123.46" String.Format("{0:0.##}", 123.4); // "123.4" String.Format("{0:0.##}", 123.0); // "123"
71 Views
no comments
using System; using System.Collections.Generic; using System.Xml.Linq; using FizzWare.NBuilder; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests.Reporting { [TestClass] public class DynamicXmlFormatting
128 Views
no comments
using System; using System.Collections.Generic; using FizzWare.NBuilder; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests.Reporting { [TestClass] public class DynamicTextFormatting {
137 Views
no comments
select * from INFORMATION_SCHEMA.COLUMNS where table_name not like 'v%' order by TABLE_NAME, ORDINAL_POSITION select * from INFORMATION_SCHEMA.ROUTINES select * from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE SELECT s.name [SPECIFIC_SCHEMA], o.name [SPECIFIC_NAME], s.name [ROUTINE_SCHEMA], o.name [ROUTINE_NAME], case when o.[type] in ('P', 'PC') then 'PROCEDURE' when o.type in ('V') then 'VIEW'
80 Views
no comments
int intValue = 1512; string stringValue = intValue.ToString("#,#", CultureInfo.GetCultureInfo(Thread.CurrentThread.CurrentCulture.Name)); /* Result in US English (en-US) will be 1,512 Result in Swedish (sv-SE) will be 1 512 */
298 Views
no comments
public static class HenriFormatter { private static string OutExpression(object source, string expression) { string format = ""; int colonIndex = expression.IndexOf(':'); if (colonIndex > 0) { format = expression.Substring(colonIndex + 1);
176 Views
no comments
// get from // http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_20759950.html function fixedLengthNumber(num, size) { var str = num.toString(); var l = size - str.length; for (i = 0; i < l; i++) { str = "0" + str; } return str;
293 Views
no comments
/// <summary> /// Allows setting of a value in a UrlEncoded string. If the key doesn't exist /// a new one is set, if it exists it's replaced with the new value. /// </summary> /// <param name="urlEncoded">A UrlEncoded string of key value pairs</param> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public static string SetUrlEncodedKey(string urlEncoded, string key, string value) {
563 Views
no comments
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Text; using System.Threading; using System.Globalization;
387 Views
no comments
// 2010-10-12: Code has moved to http://bitbucket.org/jonsagara/extensionmethods/
268 Views
no comments
public static string LOSSerializeObject(object obj) { System.Web.UI.LosFormatter output = new System.Web.UI.LosFormatter(); StringWriter writer = new StringWriter(); output.Serialize(writer, obj); return writer.ToString(); } public static object LOSDeserializeObject(string inputString) {
382 Views
no comments
public static string KeyToString(object itemKey) { using (TextWriter writer = new StringWriter()) { LosFormatter formatter = new LosFormatter(); formatter.Serialize(writer, itemKey); return HttpUtility.UrlEncode(writer.ToString()); } }
240 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
