Browse by Tags

All Tags » snippet » C# (RSS)
so i needed to count the lines of a bunch of different filetypes in a folder. i decided to try using linq for this. here's what i came up with. basically a single linq statement =P you can tune the regex to taste. i just said (i think, i'm not...
Posted by royashbrook | with no comments
Filed under: ,
Stack q = new Stack(); q.Push(argument); while (q.Count > 0) { string d = q.Pop().ToString(); Console.WriteLine(d); foreach (string sd in Directory.GetDirectories(d)) q.Push(sd); }
Posted by royashbrook | with no comments
Filed under: ,
Found something nifty I didn't know about today. create multiple objects in a single using statement. I figured i would include some sample code i use for compression/decompression. I'm using the #ziplib libraries, but you could use any stream...
Posted by royashbrook | with no comments
Filed under: ,
foreach ( IPAddress ip in Dns .GetHostEntry( Dns .GetHostName()).AddressList) Console .WriteLine(ip.ToString());
Posted by royashbrook | with no comments
Filed under: ,
string sql = "some sql" ArrayList al = new ArrayList(); using (SqlConnection cn = new SqlConnection(cs)) using (SqlCommand cmd = new SqlCommand(sql, cn)) { cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection...
Posted by royashbrook | with no comments
Filed under: , ,