Format:
Recent snippets matching tags of C#
protected void Button2_Click(object sender, EventArgs e) { string uri = "http://quality.osm.no"; Uri weburi = new Uri(uri, false); StringBuilder sbuild = new StringBuilder(); string temp = ""; try { HttpWebRequest webrequest = (HttpWebRequest) WebRequest.Create(weburi); CredentialCache myCache = new CredentialCache();
9 Views
no comments
public class StoredProcedureGateway : IExternalSystemGateway { public object Call(string procedure, object[] params) { // call sproc } } public class SomeStoredProcedureParameters : IIssueExternalCalls { public string SomeString; public int SomeInt; public object IssueWith(IExternalSystemGateway gateway) {
13 Views
no comments
[TestClass] public class MyTests { static System.Threading.ManualResetEvent m_Trigger = new System.Threading.ManualResetEvent(false); [TestMethod] private static void MyTest() { Exception ex = null;
16 Views
no comments
class PrototypeTest { static void Main() { dynamic pastry1 = new Prototype(); pastry1.PastryType = "cake"; pastry1.Cake = new Func<string>(() => "awesome"); Console.WriteLine("Pastry 1's {0} is {1}.", pastry1.PastryType, pastry1.Cake());
41 Views
no comments
using System; using System.Runtime.InteropServices; using System.Security; public static class GuidUtil { [SuppressUnmanagedCodeSecurity] [DllImport("rpcrt4.dll", SetLastError = true)] private static extern int UuidCreateSequential(out Guid value);
124 Views
no comments
public DateTime getIndianStandardTime() { TimeZoneInfo IND_ZONE=TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IND_ZONE); }
27 Views
no comments
// 3.5: var radioGroups = this.Controls.OfType<RadioGroup>().ToList(); // old way using recursion: var radioGroups = GetAllRadioGroups(this.Controls); /// <summary> /// Return a list of radiogroup controls within the current controls collection, recursively /// </summary> /// <param name="controls"></param>
23 Views
no comments
public string GetMonthNumberFromAbbreviation(string mmm) { string[] monthAbbrev = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedMonthNames; int index = Array.IndexOf(monthAbbrev, mmm) + 1; return index.ToString("0#"); }
43 Views
no comments
public string GetRandomPasswordUsingGUID(int length) { string guidResult = System.Guid.NewGuid().ToString(); guidResult = guidResult.Replace("-", string.Empty); if (length <= 0 || length > guidResult.Length) throw new ArgumentException("Length must be between 1 and " + guidResult.Length); return guidResult.Substring(0, length); }
29 Views
no comments
public string GetJSONString(DataTable Dt) { string[] StrDc = new string[Dt.Columns.Count]; string HeadStr = string.Empty; for (int i = 0; i <> { StrDc[i] = Dt.Columns[i].Caption; HeadStr += "\"" + StrDc[i] + "\" : \"" + StrDc[i] + i.ToString() + "¾" + "\",";
60 Views
no comments
/************************************************************/ /* Set expectations for a method to be called only once */ /************************************************************/ // NMock: Expect.Once.On(mockLookupList).Method("Clear"); // Rhino Mocks mockLookupList.Expect(x => x.Clear()).Repeat.Once(); /************************************************************/
31 Views
no comments
var results = from e in exposureGrouping group e by new { e.Category, e.Area } into g orderby g.Key.Category, g.Key.Area select new WorldwideExposure { Category = g.Key.Category, Area = g.Key.Area, Open_Market = g.Where(x => x.ClassCode == "OM").Sum(x => x.Usd_Gross_Exposure), North_American_Binders = g.Where(x => x.ClassCode == "NA").Sum(x => x.Usd_Gross_Exposure),
74 Views
no comments
var groupedResults = from r in results group r by r.Category into g select new { Category = g.Key, Results = g };
34 Views
no comments
using System; using System.Runtime.InteropServices; namespace ShivaVG { public enum VGboolean { VG_FALSE = 0, VG_TRUE = 1 }; public enum VGUArcType {
59 Views
no comments
var reportTypes = new Dictionary<int, string> () { {(int)ReportType.Country, "By Country"}, {(int)ReportType.CountryState, "By Country, State"}, {(int)ReportType.CountryStateZone, "By Country, State, Zone"}, {(int)ReportType.CountryStatePostCode, "By Country, State, Postal code"}, {(int)ReportType.CountryZone, "By Country, Zone"}, {(int)ReportType.CountryStateCounty, "By Country, State, County"}, };
64 Views
no comments
private static bool AttemptInsertUniqueItem<T>(T item, Action<T> insert) { bool success = false; try { insert(item); success = true; } catch (SqlException sqlEx)
59 Views
no comments
public class ConsoleSpinner { const int MaxSegmentIndex = 3; readonly char[] _segments = new [] { '\\', '|', '/', '-'}; readonly int _left; readonly int _top; int _curIndex;
141 Views
no comments
public interface ICriteriaQuery<TEntity> { DetachedCriteria Criteria { get; } } public interface ILinqQuery<TEntity> { Expression<Func<TEntity, bool>> Expression { get; } }
76 Views
no comments
[Test]
public void CompileStringReversal()
{
var coffee_script =
@"reverse: (string) ->
string.split('').reverse().join ''
alert reverse '.eeffoC yrT'";
var expected =
@"var reverse;
76 Views
no comments
public static class TinyUrl { private static readonly Random Random = new Random(); public static string Get() { int random = Random.Next(); return Base62ToString(uint.MaxValue); }
57 Views
no comments
public class GenericComparer<T> : IComparer<T> { public List<Tuple<string, bool>> Comparisons { get; set; } public int Compare(T x, T y) { int returnValue = 0; IComparable xval; IComparable yval;
59 Views
no comments
public class SqlAppender : AppenderSkeleton { private static readonly string CommandText = "INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"; public string ConnectionString { get; set; } protected override void Append(LoggingEvent loggingEvent) { using (var conn = new SqlConnection(ConnectionString)) using (var cmd = new SqlCommand(CommandText, conn))
64 Views
no comments
using System; using System.Runtime.InteropServices; using System.Threading; using AcroPDFLib; // Related to: http://stackoverflow.com/questions/2702164 namespace ComConsoleApplication { [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("00000016-0000-0000-C000-000000000046")] public interface IMessageFilter
80 Views
no comments
slickGrid.AddColumn(
Column.ForId("riga")
.Named("Riga")
.ForField("id")
.WithEditorFunction("TextCellEditor")
.WithSetValueHandler("updateItem")
.WithBehavior(Column.Behavior.selectAndMove)
).AddColumn(
Column.ForId("codice")
.Named("Codice")
177 Views
no comments
namespace Nowcom.Quicksilver { using System.ComponentModel; using System.Linq.Expressions; using System; public abstract class PropertyChangedBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged;
110 Views
1 comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
