Archive
Yield keyword in C# – Reduces LOC
Yield keyword is employed to reduce the allocation of arrays and by using a simple foreach iterative control structure.
Here’s a simple program which displays the first five even numbers.
1: private void LearnYield_Click(object sender, EventArgs e)
2: {
3: // this is the main program
4: string result = String.Empty;
5:
6: foreach (int value in ShowEvenNum(2, 5))
7: {
8: result = result + " - " + value.ToString();
9: }
10:
11: MessageBox.Show(result);
12: }
13:
14: // this method returns the list of first five even numbers
15: public static IEnumerable<int> ShowEvenNum(int number, int multiplier)
16: {
17: int loopValue = 0;
18: int numberResult = 0;
19:
20: while (loopValue < multiplier)
21: {
22: numberResult += number;
23: loopValue++;
24:
25: // this yield keyword will directly add to the return list
26: yield return numberResult;
27: }
28:
29: }
This code and its comments are self explanatory.
-Yuva
SCSF for Visual Studio 2008 SP1
This is regarding the installation of SCSF for Visual studio 2008 SP1.
Here you can see lot of issues for the release of SP1 with SCSF
http://smartclient.codeplex.com/wikipage?title=Known%20Issues%20%2f%20Fixes&referringTitle=Home
Yes, The fix is also available for this.
Downoad the solution from the link below
1. Open and build the GuidancePackage.sln solution to generate the installer.
2. Navigate to the SmartClientFactorySetup\Debug folder.
3. Close all instances of Visual Studio.
4. Run the SmartClientFactoryPackageSetup.msi installer.
And now open the VS 2008 instance and check for the new project and you will see the image as below.
Click on the newer version and enjoy coding.
-Yuva