Welcome To Snipplr


Everyone's Recent C# Snippets Tagged c



Read the [best article on the subject - Exploring Secrets of Persistent Application Settings](http://www.devx.com/dotnet/Article/33944/1954) - and then the following links if desired. (Note, I recommend reading [this forum post about settings not bei...
0 1470 posted 14 years ago by pckujawa
You can change your dynamic binding eval text with this method. This method should be in same codebehind
0 622 posted 14 years ago by emregulcan
Loop through the ListView Control within 2nd level collection. 2nd level means it's within another control (ie table html generic control).
0 1107 posted 14 years ago by the_menace
Snippet out of my C# KNN implementation. Uses leave-one-out cross validation tuning with our given K to find our nearest neighbors.
0 732 posted 14 years ago by ahawker
0 416 posted 14 years ago by fredblogs
Another common task when working with strings is to replace a set of characters with a set of escape sequences. Sometimes the replacement is very easy - you only have to place a backslash (or another character) before every occurrence of an escaped c...
0 1099 posted 14 years ago by quangnd
This class uses static methods to create html controls on the fly in .NET
2 766 posted 14 years ago by mpcircuitry
0 516 posted 14 years ago by wearetherock
0 441 posted 14 years ago by wearetherock
1 704 posted 14 years ago by jasonseney
A style of code reuse. Breaking methods (in this case MVC controller) into very small reusable atomic chunks that either perform an operation then return an ActionResult OR return null, then using with the null-coalescing operator.
0 635 posted 14 years ago by jmcd
Useful in cases where the object author has specified their own serialization that doesn't work for you.
1 823 posted 14 years ago by rengber
Definitely falls into the category of "simple thing I shoulda memorized years ago", but whatever:
0 641 posted 14 years ago by rengber
*save as proxy.asxh and put it in your IIS virtual directory *consider using other methods to circumvent XSS: JSONP, dojox.io.xhrWindowNamePlugin, etc.
0 618 posted 14 years ago by stoyan
*IE7 sometimes complains that a JavaScript script is running too slow and asks the user whether they want to terminate it or continue. *To get rid of this annoying popup a few changes need to be made to the registry. *ref: http://www.itwriting.com...
0 658 posted 14 years ago by stoyan
Displaying values as hex in a PropertyGrid by using a TypeConverter class. The TypeConverter class is assigned as a property to the PropertyGrid's data element. Consider improving by making the UInt32HexTypeConverter a generic/template as in HexTy...
0 1305 posted 14 years ago by jimfred
Stupidly simple -- just one pitfall: class to be bound must have Get/Set methods for reflection to discover. Which is annoying when it comes to client side classes auto generated from WSDL.
0 739 posted 14 years ago by rengber
Basic example of calling a web service from code using GET. You can pass parameters in as query vars. Assumes return type of service is "String". Example return xml: <?xml> <string>US</string> @SNIPPLR TEAM: Please let me put xml at...
3 1121 posted 14 years ago by jasonseney
Here are some example string formats. As I discover more I will add them here.
6 739 posted 14 years ago by stewshack
This is how I read a file using C#.
3 729 posted 14 years ago by stewshack
## Markup ## _Using square [ ] brackets for compatibility with Snipplr comment form_ [asp:PlaceHolder ID="StuffHolder" runat="server" ] <p>Some stuff in here</p> [/asp:PlaceHolder] ## Code Behind ## HtmlAttr[] attribu...
1 1007 posted 14 years ago by jasonseney
Say that you have a collection of objects empty but for IDs. You want to do a foreach loop through those objects and lookup detail one at a time. Unfortunately, in the foreach, you can't replace the references, you can only copy the new detail...
1 906 posted 15 years ago by rengber
1 1361 posted 15 years ago by Unsafe
This is stupidly simple, but I always forget it.
1 738 posted 15 years ago by rengber
Will return a string that has any matched URLs wrapped in `<a>` tags. Example: `"This is a link to http://foobar.com . Please visit !"` Becomes: `"This is a link to <a href='http://foobar.com'>http://foobar.com</a> . Please visit!"` Note: Op...
2 4177 posted 15 years ago by jasonseney
Example uses an object from 3rd party API. Needed to turn it into xml for returning from a webservice.
0 566 posted 15 years ago by jasonseney