Quick-tip

There are 5 entries for the tag Quick-tip

Create IEnumerable<T> with one line in LINQ

Pretty straight-forward, but a useful snippet of code nonetheless. Given this class: public class AggregateContent { public string Title { get; set; } public string Description { get; set; } public AggregateContent(string Header, string Content) { Title = Header; Description = Content; } } You can use line to create an IEnumerable<AggregateCon... like this: IEnumerable<AggregateCon... a = LastNNewsItems.Select(p => new AggregateContent(p.NewsTitle, p.HtmlContent)); Technorati Tags:...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Searching TFS for code changes

Eventually you're going to need to search their source-control for latest changes given some parameters. I recently came across a couple of handy ways to do this, using TFS Powertools (and Powershell). First, ensure you have the latest version of TFS Powertools installed. Also ensure you have included Powershell CmdLets when you install (or make sure this option was enabled if you've already got TFS Powertools installed) To search TFS via the command line, fire up the Powershell window and execute...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Web Application Performance: CSS Data URIs

Was doing my daily research today and learned a couple of new and interesting things. A while back, I wrote a post about rendering options using .NET 3.5 SP1's charting component. I outlined a few of the more conventional/out-of-the-box methods (temporary directory, binary streaming). I also outlined a lesser-known technique in which you stream binary data to the src attribute of your <img> tag. That ends up looking like this... <img src='data:image/png;base64, iVBORw0KGgoAAAA[snip]; />...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Get the index of a given item using LINQ [quick-tip]

UPDATE: Please see first comment to do this the "safe" way... It took a bit for me to get comfortable enough with LINQ-to-objects to write ‘queries’ off the top of my head…but once you’re used to it you realize it’s much more concise, easier to interpret/read, and well..it’s less code. Here are some real quick examples… This first example selects the string array value as well as its position from the someItems array. Note, the user of new{} creates a new generic type that has the properties ItemName...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Returning values from your LINQ queries [quick tip]

Just a quick tip that I found handy while doing some writing yesterday; chances are if you’ve played with LINQ you probably wrote something like this… var outputString = from s in inputString where s.Length > 1 select s; //Do some stuff with outputString in your method... Code like the above will work perfectly well if what you’re going to work with your implicit variable, outputString, within the body of the same method. But, as it stands, you can’t return outputString, or any implicit variable...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Twitter