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#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;
 
namespace HelpDesk.Models {
    public interface IGenericRepository {
        IQueryable<T> Get<T>() where T : class;
        void Insert<T>(T item) where T : class;
by davecowart   Wednesday @ 1:49pm
9 Views
no comments
 
C#
public IEntity GetFromReader(IDataReader reader)
        {
            QueueItem entity = new QueueItem();
            entity.PrimaryQueueID = DataMapper.IsNull<long>(reader["PrimaryQueueID"], new long());
            entity.PaymentRequest = DataMapper.IsNull<string>(reader["PaymentRequest"], string.Empty);
 
            return (IEntity)entity;
        }
March 11, 2010 @ 2:45am
6 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Runtime.Serialization;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq.Expressions;
by Jerry Nixon   March 05, 2010 @ 9:36am
Tags: C#, LINQ, LINQ2SQL
24 Views
no comments
 
XML
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="HL7v2xConformanceProfile">
        <xs:annotation>
            <xs:documentation>An unambiguous specification of one or more standard HL7 messages that have been analyzed for a particular use case.  It prescribes a set of precise constraints upon one or more standard HL7 messages.</xs:documentation>
            <xs:appinfo>
                <sch:pattern name="Check for no optionality in Implementation profiles">
                    <sch:rule context="HL7v2xConformanceProfile">
                        <sch:report test="@ProfileType='Implementation' and count(HL7v2xStaticDef/descendant::*[@Usage='O'])!=0">May not have elements with a Usage of 'O' in an Implementation profile.</sch:report>
                    </sch:rule>
by Richard Kavanagh   March 05, 2010 @ 9:35am
18 Views
no comments
 
// The view: Index.aspx
 
<!-- the non-AJAX form to filter the list -->
<% using (Html.BeginForm()) { %>
    <fieldset>
    <legend>Search</legend>
    <input name="SearchTerm" />
    <input type="submit" value="Go" />
    </fieldset>
<% } %>
by Jerry Nixon   March 05, 2010 @ 9:32am
Tags: C#, AJAX, MVC
21 Views
no comments
 
C#
//
// GlossaryController.cs
 
public ActionResult Index()
{
    return View(Models.Term.SelectAll());
}
 
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection collection)
by Jerry Nixon   March 05, 2010 @ 9:29am
Tags: C#, AJAX, MVC
21 Views
no comments
 
C#
var _Offspring = _Context.Users   
        .SelectMany(x => x.Offspring).Distinct();
by Jerry Nixon   March 05, 2010 @ 8:44am
13 Views
no comments
 
C#
// handle the completed event 
_Service.MyMethodCompleted += (s, e) =>
{
    // an Action is just a built-in delegate 
    Action _Action = () =>
    {
    // access the UI here
    this.MyLabel.Text = e.Result;
    }
    // change the thread context
by Jerry Nixon   March 05, 2010 @ 8:41am
Tags: C#, Thread, Action
16 Views
no comments
 
C#
dynamic _Dynamic = new ExpandoObject();
_Dynamic.Color = "Brown";
_Dynamic.Print = new Action(() =>
    {
    Console.Write(_Dynamic.Color);
    });
_Dynamic.Print();
by Jerry Nixon   March 05, 2010 @ 8:38am
18 Views
no comments
 
C#
private void button_Click(object sender, EventArgs e) 
{ 
    // pass in the containing panel 
    LoadControl<MyControls.MyControl>(panelContainer); 
} 
 
void LoadControl<T>(Panel panel) where T : Control, new() 
{ 
    T _Control = GetControl<T>(panel); 
    if (_Control == null) 
by Jerry Nixon   March 05, 2010 @ 8:17am
19 Views
no comments
 
C#
<#@ template language="C#v3.5" hostspecific="True" debug="True" #> 
<#@ output extension="cs" #>
<#@ assembly name="Microsoft.SqlServer.ConnectionInfo" #>
<#@ assembly name="Microsoft.SqlServer.Smo" #>
<#@ assembly name="System.Data" #>
<#@ import namespace="Microsoft.SqlServer.Management.Smo" #>
<#@ import namespace="Microsoft.SqlServer.Management.Common" #>
<#@ import namespace="System.Data.SqlClient" #>
<#@ import namespace="System.Collections.Specialized" #>
<#
by Rob   March 04, 2010 @ 7:47am
Tags: T4, Sql, c#
29 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
 
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data;
by Matt Slay   March 03, 2010 @ 12:56pm
15 Views
no comments
 
C#
// LivePreviewPlugin.cs
//
 
using System;
using System.Collections;
using System.Html;
using System.Runtime.CompilerServices;
using jQueryApi;
 
[Imported]
by Nikhil Kothari   February 25, 2010 @ 11:25am
263 Views
1 comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
 
namespace Nixoncorp.LoopPerformance
{
    class Test
    {
by Jerry Nixon   February 23, 2010 @ 12:54pm
47 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
 
namespace Nixoncorp.LoopPerformance
{
    class Test
    {
by Jerry Nixon   February 23, 2010 @ 12:16pm
17 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
 
class Program {
    static void Main(string[] args) {
        Console.WriteLine("IFC Source File:");
by M King   February 23, 2010 @ 8:40am
Tags: IFC, C#, .NET
16 Views
no comments
 
C#
using System;
using System.Text;
 
namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {
            //ავიღოთ რაიმე სტრინგი
            string s = "me miyvars samyaro imitom rom mze amodis da natels fens yovels";
            //გადავიყვანოთ ბაიტების მასივში, რადგან Convert.ToBase64String ბაიტის მასივს იღებს პარამეტრად
            byte[] strBytes = Encoding.ASCII.GetBytes(s);//თუ გაქვთ უნიკოდური ტექსტი უნდა გამოიყენოთ შესაბამისი კლასი. მაგ Encoding.Unicode
by Zviadi   February 10, 2010 @ 4:47am
25 Views
no comments
 
C#
using System;
using System.Collections.Specialized;
using System.Web;
using System.IO;
 
namespace ConfigFileExample.Services
{
    public interface IConfigurationManager
    {
        NameValueCollection AppSettings { get; }
by Bob Cravens   February 03, 2010 @ 2:46pm
42 Views
2 comments
 
C#
        public int CryptoHash(string strValue)
{
    int hashCode = 0;
    if (strValue ! = null)
    {
        byte[ ] encodedUnHashedString =
                Encoding. Unicode. GetBytes(strValue) ;
            byte[ ] key = new byte[ 16] ;
    RandomNumberGenerator. Create( ). GetBytes(key);
        MACTripleDES hashingObj = new MACTripleDES(key) ;
by Athens Springer   January 25, 2010 @ 7:17am
Tags: C#, Hash
17 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Text;
by Athens Springer   January 22, 2010 @ 8:33am
24 Views
no comments
 
C#
public enum StyleConditions {
   IE6OrLess, IE7OrLess
}
 
public static class HtmlHelpers {
   #region Image
   public static string Image(this HtmlHelper helper, string route, string action, int id, int height, int width, int imageType,
      string altText, string cssClass) {
      var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
      var imageUrl = urlHelper.RouteUrl(route, new RouteValueDictionary(new {
by Richard Kimber   January 20, 2010 @ 1:16pm
242 Views
no comments
 
C#
//without using Object Initializer Syntax
 
                    letter = new Letter();
                    letter.Date = DateTime.Now.Date;
                    letter.RegisterDate = DateTime.Now.Date;
                    letter.LetterType = LetterType.Outgoing;
 
                    letter.LetterInformation = new LetterInformation();
                    letter.LetterInformation.RuntimeState = common.RuntimeState.Added;
                    letter.LetterInformation.Letter = letter;
by afsharm   January 19, 2010 @ 4:17am
53 Views
1 comments
 
C#
public static void ResizeImage()
{
    using (Bitmap src = new Bitmap(_ImgOriginal))
    {
        int destWidth = (int)(0.5 * src.Width);
        int destHeight = (int)(0.5 * src.Height);
        
        using (Bitmap dest = new Bitmap(destWidth, destHeight))
        using (Graphics gDest = Graphics.FromImage(dest))
        {
by Jon Sagara   January 14, 2010 @ 4:31pm
Tags: c#, gdi+, image, resize
26 Views
no comments
 
C#
public List<PersonInOrganization> ExtractInvalidEmails()
{
  EntityCollection<PersonInOrganization> list =  GetAllItems();
 
  //my first LINQ use!
  var invalids = from l in list where !string.IsNullOrEmpty(l.Email) && !IsValidEmail(l.Email) select l;
 
  return invalids.ToList<PersonInOrganization>();
}
by afsharm   January 12, 2010 @ 12:01am
40 Views
1 comments
 
C#
using System;
 
namespace SharpVM
{
    /// <summary>
    /// http://pastebin.com/f22e2c91
    /// 
    /// A little playground for VM and JIT testing.  The basic idea is to have an instruction set that is
    /// EXTREMELY EASY to decode: we prefer more instructions versus complex decoding logic.  For example, 
    /// most opcodes have a W version that lets the last argument (usually a word) take up an entire
by Fred Rosenbaum   January 05, 2010 @ 8:41am
46 Views
no 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