Dotnet

Dotnet

Using .net

Articles

Using System.Uri’s Segments property and List().ForEach

From:  fremus.co.za
You know the feeling when you see someone use a property and you go, nice, I never knew that. Well last night that happened to me after reading Scott Hanselman’s article on Windows Powershell. In the article he created a script that automatically downloaded his podcasts. To do this he use the System.Uri class which has a property called Segments. Segments returns a string array which consists of elements in a Uri separated by a forward slash ‘/’. So lets say you have this url: http... Read Full Story

Calling unmanaged code from C#

One of the objectives of Exam 70-536 is Implementing interoperability, reflection, and mailing functionality in a .NET Framework application Call unmanaged DLL functions within a .NET Framework application, and control the marshalling of data in a .NET Framework application. There are several subtopics in this requirement. The example presented today will cover Create a class to hold DLL functions; Create prototypes in managed code Call a DLL function Call a DLL function in special cases... Read Full Story

C# and streams

From:  fremus.co.za
C# uses a lot of streams, or at least it seems so in some of the code examples I have looked at. Having said that I felt the need to read up on the Stream class. The stream class is an abstract class and an abstract acts as a type of base class from which other classes can inherit. And just to recap, abstract methods do not have a method body and must be implemented by the class inheriting from it. A method marked as virtual can be overridden but it does not have to be implemented. Methods... Read Full Story

Using yield to stream database results

From:  fremus.co.za
I have been looking for a way to stream database results for a while now, and has as yet not come to a fitting solution. That is until today and after I did some reading on the yield keyword. The yield keyword can be used inside a function that implements the IEnumerable interface and what it seems to do is force a loop to return a result even though its not finished. Lets say for instance you have a function like this: public static IEnumerable Power(int number, int exponent) { int... Read Full Story

Chapter 3: Programming Basics / C# Iteration Constructs

C# Iteration Constructs Almost all programming languages I have worked with will have your simple for loop, foreach statments. So, this is just something to practice little on, we will not spend too much time on it: for loop foreach / in loop while loop do/while loop We will now examine these looping construct in a new console application. for Loop With for loop you can iterate over a block of code with a fixed number of times. That being said, you are able to specify how many times a block... Read Full Story

Linq to XML and DataSet to XML

From:  fremus.co.za
On Monday I started working through some LINQ to XML and it got me so excited that I misunderstood some project requirements that ended up being quite wrong. It did not, however, diminish my enthusiasm. I ended up using a small part of the code in the end anyway, even though it was not in a production environment. Lets say you have a collection of XML documents and you would like to know what elements appear in all of them, so at the end of it all you have a single of list of elements that... Read Full Story

File.ReadAllLines() vs StreamReader

From:  fremus.co.za
A couple of days ago I forced myself to memorize the C# code for reading from a file (text, html), and for it I used the StreamReader class ( on MSDN ): try { using(StreamReader reader = new StreamReader('filename')) { string s; while((s = reader.ReadLine()) != null) { Console.WriteLine(s); } } } catch(Exception ex) { Console.WriteLine(ex.Message); } This is in comparison to the File class which has a method called ReadAllLines, and its biggest benefit is that it results in... Read Full Story

Chapter 3: Conditional & Switch Statements

The if & else if statement Conditional statements allows us to test to see if a specific condition is met. static void Main(string[] args) { Console.WriteLine("Type is a string"); string input; input = Console.ReadLine(); if (input == "") { Console.WriteLine("You typed an empty string"); } else if (input.Length < 5) { Console.WriteLine("The string had less then 5 characters"); } else if (input.Length < 10) { Console.WriteLine("The string has at lease 5 but less" + "then 10 characters... Read Full Story

Image Processing in PHP using PEL

From:  techunits.com
Exchangeable image file format (Exif) is a specification for the image file format used by digital cameras. The specification uses the existing JPEG, TIFF Rev. 6.0, and RIFF WAV file formats, with the addition of specific metadata tags. It is not supported in JPEG 2000, PNG, or GIF.The PHP Exif Library (PEL) lets you fully manipulate Exif (Exchangeable Image File Format) data. This is the data that digital cameras place in their images, such as the date and time, shutter speed, ISO value and... Read Full Story

Using nullable types in C#

From:  fremus.co.za
I was busy reading an MSDN article on modifying an attribute’s value in an XML document and I read the bit that looks like this: int? c2 = (int?)root.Attribute("Att2"); Console.WriteLine("c2:{0}", c2 == null ? "attribute does not exist" : c2.ToString()); Notice the ternary operator after the the type. It’s saying that c2 can be null. If you wrote code like this: //declare variable int c = null; You will get a compiler error. Also notice the conditional shorthand, which is... Read Full Story
Top Geek Articles
Celebrities on the Phone
Cell phones are to celebrities like bats are to baseball: no one runs too far without them.
Why every guy should buy their girlfriend Wii Fit.
Gratuitous...
Hot Geeks -- The Sexiest Geeky Girls
These girls are gorgeous AND they'll play Warcraft with you. Doesn't get much better than that.
More From Zimbio
Copyright © 2009 - Zimbio, Inc. Some rights reserved.