Welcome To Snipplr
Everyone's Recent C# Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
This is about the simplest way I've found. See [this](http://stackoverflow.com/questions/1092463/getting-the-mac-address-of-the-remote-host) and [this](http://stackoverflow.com/questions/1092379/want-to-get-mac-address-of-remote-pc/1092392#1092392) a...
0
4295
posted 13 years ago by pckujawa
[Serializable]
[XmlRoot("items")]
public class ItemCollection : XmlSerializableCollection<Item>
{
}
0
586
posted 13 years ago by aelesbao
C#
TruncateOnWordBoundary - a useful extension method for cutting a string short, but not in the middle of a word.
Ever wanted a method that can truncate a string, but only on a word boundary? This method works like Substring() but doesn't snip a string in the middle of a word, i.e. it only truncates the string on a word boundary. Useful for producing a summary f...
1
1340
posted 13 years ago by stewartrae
.net 3.0+, To create stability in your code, you must check all inputs into a method to make sure they are valid . Often people overlook this step because of laziness, or because they aren't convinced that exceptions and assertions are actually in pl...
0
875
posted 13 years ago by bryanlyman
A simple C# function to take a standard DateTime and convert it to a pretty string saying how many seconds/minutes/days/weeks/months ago the date was, it doesn't return an actual date, but that wouldn't be hard to change the month/week/day section to...
2
861
posted 13 years ago by Maelstrom
This snippet is "extension method" for IDataReader.
You can use this snippet below ;
I assume you have datareader like that
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.IsColumnExists("columnName"))
{
//do something...
0
1286
posted 13 years ago by emregulcan
Returns the username (domain\username) of the user that is currently logged in sharepoint. Can be used inside features / custom pages
0
953
posted 13 years ago by dimian12
Not that theres anything new to this. In fact its very old fashioned, but If you like me forget how its done; snip it.
0
848
posted 13 years ago by fengelz
Will return the host name that the site is running on. Example:
`http://mysite.com` or `http://myspecialsite.com:102`
0
1126
posted 13 years ago by jasonseney
You need to register this at the top of the page (see code below). Remember you can do this on a layout page as well, instead of the master page.
Then place the PublishingWebControls:EditModePane tag inline (see below). The ID can be anything...
0
609
posted 13 years ago by rumremix
use this if you want to make a binary use an older version of a dependent binery
1
696
posted 13 years ago by samwa
This is far from ground breaking but I forget it all the time so thought this might be a useful place to keep a reference of it
0
866
posted 13 years ago by AndewAllison
The only way i know to create a normal "fire property changed" method that is still efficient yet strongly typed. The other common pattern uses run time checking and uses the TyepDescriptor for the current type to check for property existence - a muc...
0
526
posted 13 years ago by nimast