CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of C#
C#
public static class Extensions {
 
    public static IEnumerable<T> Select<T>(
        this SqlDataReader reader, Func<SqlDataReader, T> projection) {
 
        while (reader.Read()) {
            yield return projection(reader);
        }
    }
}
by jaredmroberts   April 10, 2012 @ 2:24pm
Tags: c#, sqlclient
25 Views
no comments
 
C#
So I have a database that has two columns I want to access:
 
YEAR
EQ_MAG_MW
 
I'm using the following C# code to try to get at the data into a string called year but it isn't working:
 
<code>
    int columnIndex = reader.GetOrdinal("YEAR");<br />
    string year = reader.GetString(columnIndex);
by CajunTechie   March 25, 2012 @ 3:26pm
Tags: c#, .net
35 Views
no comments
 
C#
 
using Moq;
using NUnit.Framework;
using StructureMap;
 
namespace StackOverflow.Question
{
#region Commands
    public interface ICommand
    {
by Olle   February 28, 2012 @ 1:32pm
23 Views
no comments
 
C#
 
namespace System.Threading
{
    /// <summary>
    /// Extensions for <see cref="SynchronizationContext"/>.
    /// </summary>
    public static class SynchronizationContextExtensions
    {
        /// <summary>
        /// Dispatches an <b>asynchronous</b> message to a synchronization context.
by SandRock   February 24, 2012 @ 7:14am
Tags: c#
38 Views
1 comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Dynamic;
using System.Reflection;
using System.Collections;
 
namespace Westwind.Utilities.Dynamic
{
    /// <summary>
by Rick Strahl   January 31, 2012 @ 5:48pm
Tags: C#, Expando, MixIn
569 Views
2 comments
 
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (HttpContext.Current.Request.IsAuthenticated)
    {
        ResetFormsAuthenticationTicket();
    }
    else
    {
        Response.Redirect("~/logout.aspx");
    }
by Kent   January 22, 2012 @ 7:26pm
43 Views
no comments
 
C#
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
 
namespace System.Text {
    public static class StringTransformer {
        static readonly string linkFormat = "<a href=\"{0}\" title=\"{0}\" target=\"{2}\" class=\"{3}\">{1}</a>";
 
        /// <summary>
by SandRock   January 20, 2012 @ 11:21am
Tags: C#, url, html, link
99 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Web;
 
/// <summary>
/// Summary description for OrderByHelper
/// </summary>
by jaredmroberts   January 12, 2012 @ 4:49pm
61 Views
no comments
 
C#
// FlowDesign C#, classic EBC
// 4.1.2012, Christof Konstantinopoulos
// Diagram : https://cacoo.com/diagrams/Vy5LOUn5NfhTARzj
 
// File : Program.cs
 
namespace FlowDesign_KlassischesEBC
{
    class Program
    { 
by Christof Konstantinopoulos   January 04, 2012 @ 6:59am
Tags: EBC, C#
79 Views
1 comments
 
C#
using System;
using System.Text;
 
namespace MwSt_cSharp
{
    class Program
    {
        static Platine MainBoard = null;
 
        static void Main(string[] args)
by Christof Konstantinopoulos   December 31, 2011 @ 12:06pm
59 Views
no comments
 
C#
namespace Westwind.Utilities.Data
{
    /// <summary>
    /// This class provides an easy way to turn a DataRow 
    /// into a Dynamic object that supports direct property
    /// access to the DataRow fields.
    /// 
    /// The class also automatically fixes up DbNull values
    /// (null into .NET and DbNUll to DataRow)
    /// </summary>
by Rick Strahl   December 27, 2011 @ 3:56pm
294 Views
no comments
 
C#
namespace DataFieldMappingConsoleSample
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
 
    class Program
    {
61 Views
no comments
 
C#
namespace DataFieldMappingConsoleSample
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Linq;
    using System.Reflection;
 
    [AttributeUsage(AttributeTargets.Property)]
51 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
 
namespace Westwind.Web.Services
{
    /// <summary>
    /// Implements the Gravatar API for retrieving a Gravatar image to display
by Rick Strahl   December 15, 2011 @ 4:08pm
Tags: Gravatar, C#, .NET
261 Views
2 comments
 
C#
Rectangle m_Rectangle;
TranslateTransform m_Transform;
Microsoft.Devices.Sensors.Accelerometer m_Accelerometer;
 
public MainPage()
{
    InitializeComponent();
    Loaded += MainPage_Loaded;
    Unloaded += (s, e) => { m_Accelerometer.Stop(); };
}
by Jerry Nixon   December 13, 2011 @ 11:03am
277 Views
no comments
 
C#
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"));
by Jerry Nixon   December 06, 2011 @ 8:10am
Tags: C#, Format
105 Views
no comments
 
C#
public abstract class ViewModelBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    protected void RaisePropertyChanged(string property)
    {
        if (PropertyChanged == null)
            return;
        PropertyChanged(this,
            new PropertyChangedEventArgs(property));
        PropertyChanged(this,
by Jerry Nixon   November 08, 2011 @ 10:39am
Tags: MVVM, C#
148 Views
no comments
 
C#
public static IEnumerable<Orders> ExcludeOrderTypes(this IEnumerable<Orders> orders, int[] orderTypeIdsToExclude)
{
 
    if ((orders == null || orders.Count == 0)) {
        return new List<Orders>();
    }
 
    if ((orderTypeIdsToExclude == null)) {
        return orders;
    }
by Cat   October 30, 2011 @ 11:07pm
Tags: C#, LINQ, Exclude
60 Views
no comments
 
C#
// Format names as one comma delimited string
var names  = string.Join(", ", (from p in people select d.Name).ToArray());
by Cat   October 30, 2011 @ 3:31pm
Tags: C#, LINQ
88 Views
no comments
 
C#
public MainPage()
{
    InitializeComponent();
 
    var _List = new List<InputScopeNameValue>();
    for (int i = 0; i < 100; i++)
        _List.Add((InputScopeNameValue)i);
    listBox1.ItemsSource = _List;
}
by Jerry Nixon   October 25, 2011 @ 12:54pm
Tags: WP, C#
103 Views
1 comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate