Browse by Tags

Webclient downloading content/files from an Https (SSL)
Monday, October 05, 2009 2:09 AM
i was using the webclient object to download files from a website and my application worked fine. my client decided to add an SSL certeficate to the website and has required me to change my code to request the file through https instead of http all i had to do was change the URL to have https:// instead of http:// but when i first tried the code. i got this exception... Read More...
by amir.magdy | 1 comment(s)
Filed under: ,
Yield in c#
Monday, February 25, 2008 3:47 AM
i've been trying to explain the keyword yield to a friend of mine for more than an hour and he did not get it. but finally when i typed in this example he finally did 1: class enu :IEnumerable 2: { 3: public IEnumerator GetEnumerator() 4: { 5: yield return 1; 6: yield return 2; 7: yield return 3; 8: } 9: } it actually means that when you are enumerating this... Read More...
by amir.magdy | 15 comment(s)
Filed under: ,
Delegates to LINQ [passing logic as a parameter] (part I)
Friday, February 08, 2008 9:03 AM
it's normal to pass data to a function just thow in a parameter of the type of data you want to pass and ur set public int add ( int i, int u ){ return i+u; } now think in a different way, u now want to build a set of operations that the user can choose from now what you need is to build a function that would take the user's input and the operation as... Read More...
by amir.magdy | 3 comment(s)
Filed under: ,
Have u ever needed to extend a string? [Extension Methods]
Thursday, December 27, 2007 6:34 AM
well it's not inheritable by default so you can not extend it. that used to be the case before c# 3.0 now you can specify all the functionality that you need in an Extension Method. problem lies in that the extension method needs to access the instance of the object you are extending well, it goes like this 1- first you declare a static class with ur static... Read More...
by amir.magdy | 8 comment(s)
Filed under: ,
Object and Collection Initializers
Wednesday, December 26, 2007 5:03 AM
well also one of the nicest features in c# 3.0 is the object initializers well we used to do this 1: Employee emp = new Employee(); 2: emp.FirstName= "Amir" ; 3: emp.LastName= "Magdy" ; 4: emp.Title = "Mr." ; i actually hated writing this previous snippet now in c# 3.0 we do this 1: var emp = new Employee {FirstName= "Amir"... Read More...
by amir.magdy | 3 comment(s)
Filed under: ,
Auto Implemented Properties
Monday, December 24, 2007 2:23 AM
C# 3 comes with a very nice feature (not undermining the power of lambda expressions and Linq), just this one shows how nice the language has evolved into 1: class Employee 2: { 3: public string firstName { get; set; } 4: } you see the previous code will act as a full blown property that maintains its instance value internally the compiler creates a member and... Read More...
by amir.magdy | 1 comment(s)
Filed under: ,