This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Index(Model model) | |
{ | |
if (ModelState.IsValid) | |
{ | |
// do stuff here | |
} | |
else | |
{ | |
foreach (ModelState modelState in ViewData.ModelState.Values) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This hosts file is brought to you by Dan Pollock and can be found at | |
# http://someonewhocares.org/hosts/ | |
# You are free to copy and distribute this file, as long the original | |
# URL is included. See below for acknowledgements. | |
# Please forward any additions, corrections or comments by email to | |
# [email protected] | |
# Last updated: Feb 17th, 2013 at 13:37 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main() | |
{ | |
string s = "Hello Extension Methods"; | |
int i = s.WordCount(); | |
} | |
} | |
public static class MyExtensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main() | |
{ | |
IEnumerable<string> names = new string[] { "Ireland", "Brazil", "Iceland" }; | |
foreach (var name in names.Filter(predicate: StringThatStartWithI)) | |
{ | |
Console.WriteLine(name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static byte[] Foo() | |
{ | |
using (var memStream = new MemoryStream()) | |
using (var streamWriter = new StreamWriter(memStream)) | |
{ | |
for (int i = 0; i < 6; i++) | |
streamWriter.WriteLine("TEST"); | |
streamWriter.Flush(); | |
return memStream.ToArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d - Short date | |
%d - Day number | |
M?d - Month and day number | |
dd - Day number, two digits | |
ddd - Abbreviated day name | |
dddd - Full day name | |
f - Full (long date, short time) | |
%f - Fractions of second, one digit | |
s^f - Seconds and fractions of second, one digit | |
ff - Fractions of second, two digits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String Sha1(String plainText) | |
{ | |
Byte[] text, hashBytes; | |
using (SHA1Managed sha1 = new SHA1Managed()) | |
{ | |
text = Encoding.Unicode.GetBytes(plainText); | |
hashBytes = sha1.ComputeHash(text); | |
} | |
return Convert.ToBase64String(hashBytes); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Package EntityFramework.SqlServerCompact | |
Install-Package MvcScaffolding | |
public class Task | |
{ | |
[Key] | |
public int TaskId { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main() | |
{ | |
const string apiKey = "99999999999999999999999999999999-us2"; // Replace it before | |
const string listId = "b999jw9999"; // Replace it before | |
var options = new List.SubscribeOptions{DoubleOptIn = true,EmailType = List.EmailType.Html,SendWelcome = false}; | |
var merges = new List<List.Merges> { new List.Merges("[email protected]", List.EmailType.Html) { { "FNAME", "John" }, { "LNAME", "Smith" } } }; | |
var mcApi = new MCApi(apiKey, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private MemoryStream GetFakeStream(string s) | |
{ | |
MemoryStream stream = new MemoryStream(); | |
StreamWriter writer = new StreamWriter(stream); | |
writer.Write(s); | |
writer.Flush(); | |
stream.Position = 0; | |
return stream; | |
} |
OlderNewer