Visual C# Language ForumIssues regarding the C# language and compiler – including things like generics, anonymous methods, etc.© 2009 Microsoft Corporation. All rights reserved.Wed, 25 Nov 2009 22:57:52 Zee0ba90b-2020-4d46-848e-7278d11047e8http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/bfca8747-fea8-42cd-8cbe-e78ee7462ef7http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/bfca8747-fea8-42cd-8cbe-e78ee7462ef7YKiranKumarhttp://social.msdn.microsoft.com/Profile/en-US/?user=YKiranKumarWindows Service Start Failure error..All,<br/><br/> I'm getting an error message like &quot;Cannot start service from the command line or a debugger. A windows service must frist be be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.&quot; when I started debugging my service from VS 2008 Professional Edition. Following is how I using my 'OnStart(...)' method:<br/><br/>private bool IsStarted = true;<br/>private NotificationProcessBusiness notificationProcess = null; // Initializes in CTOR<br/><br/>...<br/><br/>protected override void OnStart(string[] args)<br/>{ <br/>   if (IsStarted)<br/>   {<br/>      notificationProcess.StartNotificationProcess();<br/>      IsStarted = false;<br/>   }<br/>}<br/><br/>...<br/><br/>I am not sure why this error is occuring. I googled all sites but no idea about the solution. <br/><br/>Please can some one help me in resolving this problem.<br/><br/><hr class="sig">Kiran (www.ggktech.com)Mon, 19 Oct 2009 09:03:14 Z2009-11-25T22:57:52Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3d4d2eb0-2f49-485d-ba99-1e5fa77d7599http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3d4d2eb0-2f49-485d-ba99-1e5fa77d7599ananda vardhanahttp://social.msdn.microsoft.com/Profile/en-US/?user=ananda%20vardhanaHow to use BigInteger in C#<p>The following c# sample program on VS2005 gives the following error:<br/><br/>No overload for method 'BigInteger' takes '1' arguments<br/><br/>Could this be because of vjslib.dll? I have J# installed. Anyway that is a dll, is there any lib to be used? Or any reference to be done? My .Net is 2.0, should I go tp .net 4.0? Would that help? <br/><br/><br/><br/>using System;<br/>using System.IO;<br/>using Microsoft.CSharp;</p> <p>namespace Test<br/>{<br/>    class BigInteger<br/>    {<br/>        static void Main(string[] args)<br/>        {<br/>            BigInteger bigIntFromDouble = new BigInteger(179032.6541);<br/>            Console.WriteLine(bigIntFromDouble);<br/>            BigInteger bigIntFromInt64 = new BigInteger(934157136952);<br/>            Console.WriteLine(bigIntFromInt64);<br/>        }<br/>    }<br/>}</p>Wed, 25 Nov 2009 01:30:08 Z2009-11-25T22:57:23Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/48bcea49-336a-4192-bc38-5c6ca0a0c185http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/48bcea49-336a-4192-bc38-5c6ca0a0c185Lunatikkhttp://social.msdn.microsoft.com/Profile/en-US/?user=LunatikkThe process cannot access the file because it is being used by another processHello there,<br/> <br/> I created a little app that basically watches over the file system and if a specific file is created does stuff with the file.<br/> I'm having a little problem here.<br/> First, if a file was created, the Filewatcher eventhandler gets active.<br/> After this and some other steps I try to create a XMLReader with the path of the new file (the same path, that the filewatcher watches).<br/> But at this point I get the IOexception &quot;The process cannot access the file 'D:\blah\file.xml' because it is being used by another process&quot;.<br/> <br/> However if I add a messagebox in the filewatcher or a Thread.sleep(), I get no error message.<br/> <br/> My guess is, that the file watcher somehow still has exclusive control to the file or filepath and so the XMLReader can't retrieve it.<br/> If I add a pause in between, the file watcher &quot;has enough time to release the filepath or the file&quot;. (please excuse my wording)<br/> <br/> Could somebody explain to me what the reason to this problem is?<br/> <br/> Info: Filewatcher and XMLReader are in differen classes (filewatcher static method in static class and XMLReader Method of class instance).<br/> <br/> <br/> regards,<br/> <br/> <br/> L.<br/><hr class="sig">&quot;veritas vos liberabit&quot;Wed, 25 Nov 2009 21:22:05 Z2009-11-25T21:22:05Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/80887608-7f0b-4be6-9caf-552c9406385dhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/80887608-7f0b-4be6-9caf-552c9406385dmoiseswchttp://social.msdn.microsoft.com/Profile/en-US/?user=moiseswcEasiest way to do a puzzle program??Hi,<br/>i want to make a simple puzzle program, that displays unordered buttons, like this:<br/><a href="http://img109.imageshack.us/img109/45/unor.jpg">http://img109.imageshack.us/img109/45/unor.jpg</a><br/><br/>and the user must order them, like this:<br/><a href="http://img524.imageshack.us/img524/8792/ordered.jpg">http://img524.imageshack.us/img524/8792/ordered.jpg</a><br/><br/>i was wondering what would be the easiest way to make a program like this.<br/>Using the Point class would be good?<br/><br/>thanksWed, 25 Nov 2009 08:31:50 Z2009-11-25T20:52:02Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ebc19e10-16e7-4ff2-8ac1-c1992752a65chttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ebc19e10-16e7-4ff2-8ac1-c1992752a65cnome banahttp://social.msdn.microsoft.com/Profile/en-US/?user=nome%20banaLong text in RichTextBoxI have a problem with RichTextBox: <br/>When I load a short text it works well, But when I load a long text which need scrollbars - I see a blank control and I should click it so that the text will appear.<br/><br/>Can anyone help me?Mon, 23 Nov 2009 17:37:45 Z2009-11-25T20:34:37Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/71233754-1468-49d5-bd99-5a9cfbdd8233http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/71233754-1468-49d5-bd99-5a9cfbdd8233maporojohttp://social.msdn.microsoft.com/Profile/en-US/?user=maporojoSetting MDI Child Form Position<p>Situation:</p> <p>I am learning how to make Multiple Document Interface applications in C# using Visual Studio 2008. There are features like cascade, tile, etc. that can be used to place the child form within the parent form. I'm using show and hide properties to display only one child form at a time. They are displayed as expected but they keeping moving further and further away from location (0,0) of the parent form in the process of switching forms using command buttons. I'd like to have every child form to be at location (0,0) of the parent form so that that the active form (the one where &quot;Show&quot; is &quot;True&quot;) can be completely visible in the parent form which is just slightly bigger than all the child forms. I can always resized the parent form during program execution but that shouldn't be necessary, I think.</p> <p>Question:</p> <p>Is there a way to specify the position of a child form when showing it? E.g. what would I need to add to the following code in order to make frmchild always appear at location (0,0) or (20,10) of frmparent?</p> <p>public class frmparent<br/>{<br/> .<br/> .<br/> .</p> <p> private void FileNew_clicked(object sender, EventArgs e)<br/> {<br/>  Form frmchild=new Form();<br/>  frmchild.MDIParent=this;<br/>  frmchild.Show();<br/> }</p> <p> .<br/> .<br/> .</p> <p>}</p>Wed, 25 Nov 2009 20:13:30 Z2009-11-25T20:13:31Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/0184dbfc-399e-48e4-8d48-ba36df4d019chttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/0184dbfc-399e-48e4-8d48-ba36df4d019cE_goldhttp://social.msdn.microsoft.com/Profile/en-US/?user=E_goldProblem with .xsd file - refreshhi<br/>i build C# program that connect to access database.<br/>i have .xsd file that connect to database - and through this .xsd  i connect to crystal-report.<br/>this all work excellent.<br/>now, i added 2 query in the database - and the problen that i can't see them in the .xsd file<br/><br/>whay ?<br/>Wed, 25 Nov 2009 20:02:58 Z2009-11-25T20:02:59Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/fd563c45-b458-40fb-85a2-0e0f23f49012http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/fd563c45-b458-40fb-85a2-0e0f23f49012aniruddha84http://social.msdn.microsoft.com/Profile/en-US/?user=aniruddha84unable to fine an entry point named function in dll ??<p>hi all <br/><br/>i hav the C++ dll as follow ...<br/><br/>#pragma once  // add.dll start here</p> <p>using namespace System;</p> <p>namespace add {</p> <p> public ref class Class1<br/> {<br/> public:<br/> int addition(int i,int j)<br/> {<br/>  return i+j;<br/> }<br/> };<br/>}<br/><br/>i wann to Imort this dll in my C# code and i wann to use it .. i m doing as bellow ..bt its nt working .. its giving me exception that &quot;unable to fine an entry point named addition in E:\add.dll&quot;<br/><br/><br/>using System;<br/>using System.Collections.Generic;<br/>using System.Linq;<br/>using System.Text;<br/>using System.Runtime.InteropServices;</p> <p>namespace mangedcode<br/>{<br/>    class Program<br/>    {<br/>        [DllImport(&quot;E:\\add.dll&quot;)]<br/>        unsafe public static extern int addition(int i, int j);<br/>        static void Main(string[] args)<br/>        {<br/>            int i = addition(10, 10); // exception occurs here</p> <p>            Console.WriteLine(i);<br/>        }<br/>    }<br/>}</p>Wed, 25 Nov 2009 12:10:43 Z2009-11-25T19:59:10Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/f1a0f5e4-00b0-4608-8005-e44df0d57289http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/f1a0f5e4-00b0-4608-8005-e44df0d57289Simon Woodshttp://social.msdn.microsoft.com/Profile/en-US/?user=Simon%20WoodsException from HRESULT: 0x800A0062 - C# only?Hi <br/> <br/> I have a COM dll which I am referencing in a C# solution. When I make a call on one of the methods on one of the COM objects I'm creating it generates the above error.<br/> <br/> However, if I create a VB console app and instantiate the same classes and execute the method it works fine. However, if I create a C# console app, I get the same error.<br/> <br/> The COM component is simply a Dll which exposes a few interfaces and a factory class. I select the same component from the References drop down<br/> <br/> In VB, the working code is <br/> <br/> <pre>Module Module1<br/> <br/> Sub Main()<br/> Dim factory = New MyComDll.CFactory<br/> Dim myObject = factory.CreateMyObject(&quot;&quot;, &quot;&quot;, &quot;&quot;)<br/> End Sub<br/> <br/> End Module</pre> <br/> <br/> <br/> In C#, my code is <br/> <br/> <pre> class Program<br/> {<br/> static void Main(string[] args)<br/> {<br/> MyComDll.CFactory factory = new MyComDll.CFactory();<br/> MyComDll.IMyInterface myObject = factory.CreateMyObject(&quot;&quot;, &quot;&quot;, &quot;&quot;);<br/> }<br/> }</pre> <br/> <br/> FYI ... I also tried to use type inference <br/> <br/> <pre> class Program<br/> {<br/> static void Main(string[] args)<br/> {<br/> var factory = new MyComDll.CFactory();<br/> var myObject = factory.CreateMyObject(&quot;&quot;, &quot;&quot;, &quot;&quot;);<br/> }<br/> }</pre> <br/> <br/> I assume I must be doing something pretty silly. I'd be grateful for a steer.<br/> <br/> <br/> Many thx<br/> <br/> Simon<br/> <br/> <br/> FYI The stack trace is as follows:<br/> <br/> System.Runtime.InteropServices.COMException was unhandled<br/>   Message=&quot;Exception from HRESULT: 0x800A0062&quot;<br/>   Source=&quot;Interop.MyCOMDll&quot;<br/>   ErrorCode=-2146828190<br/>   StackTrace:<br/>        at MyCOMDll.CFactoryClass.CreateMyObject(String p_sVar1, String p_sVar2, String p_sVar3)<br/>        at ConsoleApplication1.Program.Main(String[] args) in ....\Program.cs:line 13<br/>        at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)<br/>        at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br/>        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br/>        at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br/>        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br/>        at System.Threading.ThreadHelper.ThreadStart()Wed, 25 Nov 2009 16:09:09 Z2009-11-25T18:40:16Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/fd58a77e-f985-404f-9e70-3ddb4e038420http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/fd58a77e-f985-404f-9e70-3ddb4e038420RedRose2009http://social.msdn.microsoft.com/Profile/en-US/?user=RedRose2009Configuration File<span style="font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;color:#333333;line-height:16px">is this the right way of assigning variables inside app.config? <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">&lt;configuration&gt;</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">&lt;configSections&gt;</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><span style="font-weight:inherit;font-style:inherit;font-family:inherit;white-space:pre;padding:0px;margin:0px;border:0px initial initial"> </span>&lt;section name=&quot;variableSettings&quot; type=&quot;Namespace.Class, Assembly &quot;/&gt;<span style="font-weight:inherit;font-style:inherit;font-family:inherit;white-space:pre;padding:0px;margin:0px;border:0px initial initial"> </span></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">&lt;/configSections&gt;</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> </div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">&lt;variableSettings&gt;</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">  </div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"> &lt;add key=&quot;varName&quot; serializeAs=&quot;string&quot;  value=&quot;someValue&quot;/&gt;</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">&lt;/variableSettings&gt;</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">&lt;/configuration&gt;</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">and if so I would access it like this?:</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">string varName = ConfigurationManager.variableSettings[&quot;varName&quot;];</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><span style="font-weight:inherit;font-style:inherit;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;color:#333333;font-size:small;padding:0px;margin:0px;border:0px initial initial"><span style="font-weight:inherit;font-style:inherit;font-family:inherit;font-size:13px;line-height:16px;padding:0px;margin:0px;border:0px initial initial"><span style="font-weight:inherit;font-style:inherit;font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;font-size:small;padding:0px;margin:0px;border:0px initial initial"><span style="font-weight:inherit;font-style:inherit;font-family:inherit;font-size:11px;line-height:normal;padding:0px;margin:0px;border:0px initial initial">I am doing something wrong because it compiles but ConfigurationManager.variableSettings[&quot;varName&quot;] doesn't assign anything to varName;</span></span></span></span></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;font-size:small"><span style="font-size:11px;line-height:normal"><br/></span></span></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;font-size:small"><span style="font-size:11px;line-height:normal"><span style="font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;color:#333333;line-height:16px"> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">I am using this file inside ClassLibrary project, could this be a problem?   Yes it is! I just figured this out! heh...so much time lost...</div> <div><br/></div> </span></span></span></div> </div> </span>Wed, 25 Nov 2009 15:37:28 Z2009-11-25T18:26:18Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/9fbcd406-5340-4965-a408-5e98b260b5b0http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/9fbcd406-5340-4965-a408-5e98b260b5b0SkyesOfRockhttp://social.msdn.microsoft.com/Profile/en-US/?user=SkyesOfRockC# How to save content from two controls at the same timeI was wondering if it would be possible to: <div><br/></div> <div>First, Save content from a TextBox control,</div> <div><br/></div> <div>And second, Save content from two controls, a TextBox and a RichTextBox, at the same time.</div> <div><br/></div> <div>I have this code that was hoping to manipulate:</div> <div><br/></div> <div> <div>            if (saveFileDialog1.ShowDialog() == DialogResult.OK)</div> <div>            {</div> <div>                richTextBox1.SaveFile(saveFileDialog1.FileName);</div> <div><br/></div> <div>            }</div> <div><br/></div> <div>Any thoughts?</div> </div>Wed, 25 Nov 2009 17:05:59 Z2009-11-25T18:02:46Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/806493d9-a66e-4cb6-a257-1ef05ae33771http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/806493d9-a66e-4cb6-a257-1ef05ae33771RedRose2009http://social.msdn.microsoft.com/Profile/en-US/?user=RedRose2009reading SQL rows one at a time in c#I have to execute one SQL query in C#, and I'll get a list of rows....now....I have to use each of these rows (string variable) as input to another c# function. How do I loop these rows (string var) one at a time and send them to my C# function that will take it one by one as input? I was thinking of saving the result to some txt file but I am not allowed to do that. <div> <div><br/></div> <div>Thanks!</div> </div>Mon, 23 Nov 2009 20:52:21 Z2009-11-25T17:54:34Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/60543d39-c7b3-41bc-ab96-8655688d4c98http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/60543d39-c7b3-41bc-ab96-8655688d4c98Usha2009http://social.msdn.microsoft.com/Profile/en-US/?user=Usha2009When ItemDataBound event added to the Datalist control in the tag in the designer getting error object reference not set to an instance of the object<p>Hi!</p> <p>I have a Datalist control in a &lt;td&gt; tag of a &lt;table&gt; inside an ascx control. When I add an &quot;onItemDataBound&quot; event to the DataList tag in the designer I get an error as &quot;Object reference not set top an instance of an object&quot;. I am setting datasource to this DataList in the page_load method of ascx inside (! ispostback) once and I have previous and next buttons and on the click of these buttons I am setting datasource to this Dtalist again. Could you please let me know why this error is coming and how to avoid error and at the same time declare this event. Thanks for your help.</p> <p>Thanks and regards,</p> <p>Usha</p>Wed, 25 Nov 2009 17:36:44 Z2009-11-25T17:36:45Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/f8b0f913-cf2e-4835-a0c7-1fc903a456fchttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/f8b0f913-cf2e-4835-a0c7-1fc903a456fcSkyesOfRockhttp://social.msdn.microsoft.com/Profile/en-US/?user=SkyesOfRockc# how to format text in a richtextbox without displaying a fontdialogI was wondering whether I would be able to format text, say underlining it or making it bold, in a richtextbox just by selecting the text that you want and pressing the right button. This was my attempt: <div><br/></div> <div> <div>        private void underlineToolStripMenuItem_Click(object sender, EventArgs e)</div> <div>        {</div> <div>            richTextBox1.SelectionFont = Font.Underline();</div> <div>        }</div> <div><br/></div> <div>I was then told that it was a Non-invocable member 'System.Drawing.Font.Underline' cannot be used like a method.</div> <div>Can anyone help?</div> </div>Wed, 25 Nov 2009 16:20:18 Z2009-11-25T16:34:39Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/a87ecf54-1db8-4078-8a84-cdeb8c37ae03http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/a87ecf54-1db8-4078-8a84-cdeb8c37ae03Abdul-Talhahttp://social.msdn.microsoft.com/Profile/en-US/?user=Abdul-TalhaLimitation of Schedule TaskHi all,<br/> <br/> I ' am devloping application schedule task created using C# windows application. I want to know limitation of Schedule task.<br/> How many task can i created via c# application. Pls  reply me as soon as possible.<br/> <br/> Thanks and regards <br/> abdul.Wed, 25 Nov 2009 11:24:07 Z2009-11-25T15:37:17Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/d34fa0dd-7b80-48a2-86ba-5ab97ac974a7http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/d34fa0dd-7b80-48a2-86ba-5ab97ac974a7RedRose2009http://social.msdn.microsoft.com/Profile/en-US/?user=RedRose2009assigning values dynamicallyI will receive a string input from another function....now what I need is to assign that input to my variable <div><br/></div> <div>For example, receiving string input &quot;Monday&quot;;</div> <div><br/></div> <div>Now i want to assign that to a new variable:</div> <div><br/></div> <div>string x = &quot;monday&quot;....BUT since this will never be a constant I don't know how to do this dynamically so as the program runs it will automatically assign what ever comes to x;</div>Wed, 25 Nov 2009 15:10:26 Z2009-11-25T15:32:01Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/e9b6f1d3-38ba-4192-9e74-b2ef4783969dhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/e9b6f1d3-38ba-4192-9e74-b2ef4783969dDottor Mousehttp://social.msdn.microsoft.com/Profile/en-US/?user=Dottor%20MouseChange Folder extension... open for more details<p>Hi, I need a code able to create a folder with a different extension (for example a .dta).<br/>It is a complicate concept to express, but you have to think to a normal folder with some files into it and a different extension from Windows' one.<br/>Can you help me?</p> <p>Bye<br/>Dottor Mouse</p>Mon, 23 Nov 2009 20:01:31 Z2009-11-25T14:45:32Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/175e73dc-0710-4050-b442-e33580e38154http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/175e73dc-0710-4050-b442-e33580e38154funskehttp://social.msdn.microsoft.com/Profile/en-US/?user=funskeContent of ComboBox in a message ?How to display all items of a combobox in a message ?<br/><br/>Can't get it done, just starting with this but tried cmb.Items.Text etc without good results.<br/><br/>I guess this is a commaseperated list, this is the one I want to display in a message.<br/><br/>Thanks.<br/><br/>Wed, 25 Nov 2009 14:03:20 Z2009-11-25T15:05:03Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/01ee425f-16aa-4326-b7eb-f10ed175e2c4http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/01ee425f-16aa-4326-b7eb-f10ed175e2c4pepcoderhttp://social.msdn.microsoft.com/Profile/en-US/?user=pepcoderHow to get the value of a LinkTextBox created at runtime<p>Hi,<br/><br/>I have a cutom control called ScrollBox( A control like a textbox) where I am creating a LinkTextBox at runtime and showing the values of the linktextbox inside the scrollbox one by separated by commas.<br/><br/>I have completed the avove part.Now My doubt is I need to iterate through the ScrollBox control and remove an item on click of a LinkTextBox<br/><br/>Somehow I have done like this..<br/><br/> private void r_bonTextBox_Service_AfterMenuItemClick(object sender, EventArgs e)----&gt;click event of the LinkTextBox created at runtime<br/>  {<br/>   for (int i = 0; i &lt; r_bonTextBox_Service.PanelMain.Controls.Count; i++)<br/>   {<br/>    LinkTextBox link = (LinkTextBox)r_bonTextBox_Service.PanelMain.Controls[i];</p> <p>       Remove(((BOLinkData)link.llLinkLabel.Tag).BOID); // remove service ID<br/>   }<br/>  }<br/><br/>Note: <br/><br/> My remove method accepts an integer as follows<br/><br/><br/><br/>public void Remove(int ServiceID)<br/>{<br/> //code to delete the selected item from the textox <br/>  <br/>}<br/>     <br/>But <strong>r_bonTextBox_Service.PanelMain.Controls.Count</strong> (Name of my ScrollBox is r_bonTextBox_Service)  returns 0 if I run the above piece of code. Can anybody suggest an alternative method to achieve the same?<br/><br/><br/>Thanks in advance<br/><br/>Pep</p>Wed, 25 Nov 2009 13:23:17 Z2009-11-25T13:54:42Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/21ed7ffc-f430-48cf-9ad3-a539acffccd2http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/21ed7ffc-f430-48cf-9ad3-a539acffccd2RedRose2009http://social.msdn.microsoft.com/Profile/en-US/?user=RedRose2009app.configCan I preinitialize some string variables used by various functions inside the project (I am not talking just about connectionString but also some other regular variables that will be constant for all the functions) inside app.config?  <div><br/></div> <div>How do I use app.config with the project?  </div>Wed, 25 Nov 2009 10:24:26 Z2009-11-25T13:32:00Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/2c485501-4fd1-40ca-bfec-ea0e0a87f4c0http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/2c485501-4fd1-40ca-bfec-ea0e0a87f4c0Louis Anandhttp://social.msdn.microsoft.com/Profile/en-US/?user=Louis%20AnandWriting icons on the file headerHi,<br/> <br/> I created a file using C#. but i want to store the customized icon of the file on the file header itself and to retrieve for displaying. please some one help me to do that.<br/> <br/> Thanks in advance.<br/> <br/> Louis FMon, 23 Nov 2009 08:46:13 Z2009-11-25T12:25:59Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/15880a8e-b887-44db-a9d5-ba0ebdbbe98fhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/15880a8e-b887-44db-a9d5-ba0ebdbbe98fHarryBedihttp://social.msdn.microsoft.com/Profile/en-US/?user=HarryBediAdding to a Hashtable which already contains a keyGuys,<br/> <br/> I want to add to a hashtable which already contians the key - my code is:<br/> <br/>  Hashtable HT = (Hashtable)SystemTester.alMarginStats[0];<br/>                             ICollection AccountKeys;<br/>                             AccountKeys = HT.Keys;<br/>                             foreach (object key in AccountKeys)<br/>                             {<br/>                                 Framework.TheAccount = (LAB.cAccount)HT[key];                            <br/>                                 MarginStats = Framework.TheAccount.GetAccount();<br/> <br/>                                 RunStats = new sRunStats();<br/>                                 RunStats.MarginStats = MarginStats;<br/>                                 RunStats.GUIParameters = GUIParameters;<br/>                                 RunStats.TParameters = TParameters;<br/>                                 RunStats.TickSource = TickSource;<br/> <br/>                                 RunResults.Add(RunStats);<br/>                                 htRunStats.Add(key, RunResults);&lt;&lt;&lt;&lt;=========== This is where the code breaks<br/>                                <br/>                                 <br/>                                 this.ExplainRunResults(ResultHeader, RunStats, 3);<br/>                                <br/>                                 Framework.TheAccount = new cAccount(GUIParameters);<br/>                             }<br/> <br/> Could someone please explain what I should do?<br/> <br/> Thanks,<br/> Harry<br/>Wed, 25 Nov 2009 10:51:53 Z2009-11-25T11:19:16Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/6015831d-8b0a-4242-a991-7ee9d1caa8echttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/6015831d-8b0a-4242-a991-7ee9d1caa8ecTony.Tamhttp://social.msdn.microsoft.com/Profile/en-US/?user=Tony.TamDynamic ProgrammingHi All,<br/><br/>I want to use the new feature dynamic programming in C# 4.0.<br/><br/>dynamic a = myObject; // myObject has some properties<br/>String propertyValue = a.PopertyName; // the propertyName here is a variable<br/><br/>Is it prossible to do this by using dynamic programming?<br/><br/>Thanks!Tue, 24 Nov 2009 11:50:05 Z2009-11-25T17:27:55Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3ac9a8a0-6bc6-4930-a1b5-5bcfa7cdac2ahttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3ac9a8a0-6bc6-4930-a1b5-5bcfa7cdac2aBlueChippy16http://social.msdn.microsoft.com/Profile/en-US/?user=BlueChippy16Object that implements interface...that has List<IAnotherInterface> ?<div>I have a requirement to keep all interfaces and classes that inherit from that interface in separate libraries/namespaces. <br/><br/>One of my interfaces needs to have a List of type of a second interface:<br/>e.g.<br/><br/>public interface IYearData<br/>{<br/>int Year{...}<br/>int Total{...}<br/>}<br/><br/><br/>public interface IYears<br/>{<br/>List&lt;IYearData&gt; YearsList {...}<br/>}<br/><br/><br/>Now I want classes that implement these interfaces:<br/><br/>public YearData:IYearData<br/>{<br/>public int Year{...}<br/>public int Total{...}<br/>}<br/><br/><br/>public Years:IYears<br/>{<br/>public List&lt;YearData&gt; YearsList{...}<br/>}<br/><br/><br/>But I can't compile this because the class Years doesn't implement the interface, since YearsList should be of type IYearData and not YearData. <br/><br/>Is there any way round this? <br/><br/>We need to ship the interface library to a third party, but NOT our actual classes. <br/><br/>ANY help very gratefully received.<br/>Thx, Dave.</div>Wed, 25 Nov 2009 08:42:57 Z2009-11-25T10:19:46Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3cf5b584-b536-442d-9c0d-48432ea32ebehttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3cf5b584-b536-442d-9c0d-48432ea32ebeShreesh Onkarhttp://social.msdn.microsoft.com/Profile/en-US/?user=Shreesh%20OnkarCan we dynamically create Stored queries ( or simply queries) in MS Access using C#?I am facing problem with regard to creating stored queries in MS Access dynamically (at runtime using C# and VS 2005). I have been searching since 2 days but havnt got any related info. Can anybody plz tell me the way to do it??  Actually, I wanted to create Access database, tables and stored queries in MS Access using C#. I am done with first two but only last one is remaining. If this is not the right forum for this query, please suggest the right forum to ask the same.<br/><br/>Thanks in advance<br/>Shreesh OnkarWed, 25 Nov 2009 09:33:00 Z2009-11-25T09:53:19Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/a5448054-f264-411f-8abb-b13da493ee78http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/a5448054-f264-411f-8abb-b13da493ee78sharan189http://social.msdn.microsoft.com/Profile/en-US/?user=sharan189Gridview binding<p>I have a gridview and a panel with text box and 1 dropdown list box with a save button. On clicking the save button the gridview should be populated with the data entered in that textbox and dropdownlist. I have another submit button on the top of the page on clicking this button the data from the grid view should be stored in the database.</p> <p>Please help on how to code this!!!</p> THankx in advance!!Wed, 25 Nov 2009 04:42:36 Z2009-11-25T09:44:15Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/5ccd72f8-efd7-4ce7-ba95-4ab8fc1082bbhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/5ccd72f8-efd7-4ce7-ba95-4ab8fc1082bbggyppthttp://social.msdn.microsoft.com/Profile/en-US/?user=ggyppthow do i get C# to rexonize the keyboard in a Windows Form Application<p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:8pt;color:black;line-height:115%;font-family:'Verdana','sans-serif'">I am trying to get C# to recognize the arrow keys so I can use them in a game I am working on but I can't figure out what code is needed to get C# to recognize the keyboard.<br/>Any help would be appreciated.</span></p>Mon, 16 Nov 2009 23:33:08 Z2009-11-25T08:53:11Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/4f844d37-74c2-49ea-b978-042d3394141bhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/4f844d37-74c2-49ea-b978-042d3394141bharini_pavihttp://social.msdn.microsoft.com/Profile/en-US/?user=harini_paviWindows ServiceHow  to  create a windows service to clear the event log. Can anyone help me out ???Wed, 25 Nov 2009 04:43:47 Z2009-11-25T07:59:43Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/2e4d0be5-413f-4051-8a69-18608e32d186http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/2e4d0be5-413f-4051-8a69-18608e32d186Michele Lihttp://social.msdn.microsoft.com/Profile/en-US/?user=Michele%20LiEncoding Problem With Chinese Chars and Alphabets in a StringI have a string &quot;华文cool&quot; and I need to encode this string into byte. <br/>If I use UTF-8 I will get 6 bytes for the 2 chinese characters and 4 bytes for alphabets. <br/>If I use UTF-16 (which is Unicode) still cannot resolve the problem because it gives me 4 bytes for the 2 chinese characters and 8 bytes for alphabets. <br/>My requirement is to encode the chinese characters into 4 bytes and alphabets into 4 bytes (because there are 4 alphabets). <br/>Do I need to write a customised encoding method for such requirement?<br/>Sun, 22 Nov 2009 15:34:11 Z2009-11-25T05:22:49Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/b21c5e03-dead-42e9-bef8-d3bb74925553http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/b21c5e03-dead-42e9-bef8-d3bb74925553OdomaeBhttp://social.msdn.microsoft.com/Profile/en-US/?user=OdomaeBDuplicate DllImport errorI need to import multiple functions from a dll into my managed code.<br/> <br/> I am getting an error : Duplicate DllImport attribute when I do this.<br/> <br/> [DllImport (&quot;test.dll&quot;, Entrypoint=&quot;func1&quot;, SeLastError =true)]<br/> [DllImport (&quot;test.dll&quot;, Entrypoint=&quot;func2&quot;, SeLastError =true)]<br/> <br/> <br/> What am I missing?Tue, 24 Nov 2009 21:57:01 Z2009-11-25T02:20:19Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/dbd3fcdd-2539-4d45-9c4b-03a12a3eef8bhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/dbd3fcdd-2539-4d45-9c4b-03a12a3eef8btincho87http://social.msdn.microsoft.com/Profile/en-US/?user=tincho87DLL reference not found when changing the app pathHi everyone, sorry about my english. Im having a problem and i don't know how to fix it.<br/> <br/> This image describes all the problem.<br/> <a title=Image href="http://img412.imageshack.us/img412/7537/problemd.png" title=Image>http://img412.imageshack.us/img412/7537/problemd.png</a> <br/> <br/> Thanks a lot.<br/>Tue, 24 Nov 2009 12:55:18 Z2009-11-25T00:57:00Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/0ffb6dc3-1a29-4a76-90ab-1a490200df7chttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/0ffb6dc3-1a29-4a76-90ab-1a490200df7cBill_Thompsonhttp://social.msdn.microsoft.com/Profile/en-US/?user=Bill_Thompsonhow do you serialize html in c sharp?This thread <a href="http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/0e6a9799-3292-4031-8d32-b68f58ad0ed7">http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/0e6a9799-3292-4031-8d32-b68f58ad0ed7</a> talks about using XSD to create  C Sharp classes from XML that can be used with the XmlSerializer class to serialize and verify the xml document.<br/><br/>Is there a way to do the same sort of thing with an HTML document?  I have tried but the xsd command line says that the remote name <a href="http://www.w3.org">www.w3.org</a> cannot be resolved.<hr class="sig">Web Master and ProgrammerWed, 25 Nov 2009 00:10:57 Z2009-11-25T00:10:57Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/cebe94de-1488-4d17-98e6-e7b583bcd821http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/cebe94de-1488-4d17-98e6-e7b583bcd821__MDS__http://social.msdn.microsoft.com/Profile/en-US/?user=__MDS__Changing Calendar Type in DateTimePicker ? Hi all.<br/> Is it possible to change type of calendar in DateTimePicker ?<br/> e.g : I'm gonna replace Persian Calendar with the default calendar in DateTimePicker !<br/> Thanks<hr class="sig">Beauty is a great God blessing Tue, 24 Nov 2009 19:06:51 Z2009-11-24T22:03:59Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/81e438ed-9d35-47d7-a800-1fabab0f3d52http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/81e438ed-9d35-47d7-a800-1fabab0f3d52SkyesOfRockhttp://social.msdn.microsoft.com/Profile/en-US/?user=SkyesOfRockC# How to add a word counter to a richtextboxI am writing a word processor type program and I was wondering if there was any way to be able to count the words in the in a richtextbox control. <div>Any ideas?</div>Tue, 24 Nov 2009 16:45:49 Z2009-11-24T18:30:56Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/49b25b3b-3403-4d49-b7be-84426761f3echttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/49b25b3b-3403-4d49-b7be-84426761f3ecM Hassan Khanhttp://social.msdn.microsoft.com/Profile/en-US/?user=M%20Hassan%20Khanimport textbox text in data gridview in asp.net(using csharp)i want to post textbox1.text in mygridview after press a button .......<br/> actually my textbox1 is connected with database(sql) ...from it I select the userid(which is primary index in my sql table)<br/> and its related field are automatically display in other text box ........ so after selecting required userid i want that the data in textboxes export in gridview rows....and ... after i press my save button all gridviews rows should be save in my different table of sql...<br/> <br/> eg:<br/> <br/> texbox1=0001; //userid<br/> textbox2=Jennis; // respective name of given userid<br/> textbox3=11; // age <br/> text box4=southasia; //Country<br/> ---------------<br/> |POst button|<br/> ---------------<br/> <br/> <br/> gridview://<br/> -------------------------------------------------------------------------------------<br/>  userid              |  name                       | age                       |  Country                      <br/> -------------------------------------------------------------------------------------<br/> 001                     jennis                          11                           southsia<br/> 004                     peter                           34                           southamerica<br/> .<br/> .<br/> .<br/> .//other fiels..<br/>  <br/> /after all posting i want my data should be save in other tabel<br/> ------------------<br/> |saveAll button|<br/> ------------------<br/> <br/> this is the rough idea.... hope u guys understand....<br/> <br/> kindly reply asap..<br/> <br/> thnks<br/>Tue, 24 Nov 2009 17:59:03 Z2009-11-24T17:59:03Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3fec8892-97d1-4afb-b049-5daee05628ffhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/3fec8892-97d1-4afb-b049-5daee05628ffmoiseswchttp://social.msdn.microsoft.com/Profile/en-US/?user=moiseswcremeber button clickedhi,<br/>i want my program to remember the buttons the user has clicked.<br/><br/>lets say i have 3 buttons.<br/><br/>the user  clicks on button2,<br/>all buttons turn to disabled<br/>then the user click in another control, for example a picture box, and then the buttons turn to enabled, except button2 which was clicked in first place, and so on with the other buttons.<br/><br/>i added tag to the button clicked like this:<br/> <div style="background-color:white;color:black"> <pre> button2.Tag = <span style="color:#a31515">&quot;1&quot;</span>; </pre> </div> and then checked with an if condition:<br/> <div style="background-color:white;color:black"> <pre> <span style="color:blue">if</span> (button2.Tag == <span style="color:#a31515">&quot;1&quot;</span>) </pre> </div> but if I do this it will be bad if i have a bigger quantity of buttons.<br/>how can i solve this with another aproach?<br/>thanksSun, 22 Nov 2009 02:12:52 Z2009-11-24T17:53:29Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/660ee2e3-bb2f-433a-b21a-c6f7b3613425http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/660ee2e3-bb2f-433a-b21a-c6f7b3613425RedRose2009http://social.msdn.microsoft.com/Profile/en-US/?user=RedRose2009Abstract Class I have an abstract class that looks something like this: <div><br/></div> <div> <div>public abstract class Checking</div> <div>    {</div> <div>        protected string _D;</div> <div><br/></div> <div>        public string Location</div> <div>        {</div> <div>            get { return _D; }</div> <div>        }</div> <div>    </div> <div>       public abstract void DoSomething (string A, string B, string C);</div> <div>    }</div> <div><br/></div> <div>DoSomething function sets the _D variable like _D= some path;</div> <div><br/></div> <div>Where and how do I call for Location so that entry point of my project can get what's inside the _D?</div> <div><br/></div> <div><br/></div> <div><br/></div> </div>Tue, 24 Nov 2009 14:21:53 Z2009-11-25T18:43:55Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/19aa480f-d58c-4ddb-bef3-ac76eb0817c3http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/19aa480f-d58c-4ddb-bef3-ac76eb0817c3VIVEK YJAhttp://social.msdn.microsoft.com/Profile/en-US/?user=VIVEK%20YJAtypeOf() Vs Type.GetType()Hi All,<br/> <br/> Is there any difference between typeOf() and Type.GetType()? <br/> <br/> Which one is better to use based on performance?<hr class="sig">Cheers, Vivek Jain | SE | BangaloreTue, 24 Nov 2009 12:37:12 Z2009-11-24T17:35:07Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/14e07868-3e40-42cd-9379-f3bea3d06abahttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/14e07868-3e40-42cd-9379-f3bea3d06abaS.Kumarhttp://social.msdn.microsoft.com/Profile/en-US/?user=S.KumarProblem with UDPClient.Connect()HI ! <br/>I have a strange problem with UDPClient.Connect method. When I create a udpclient and connect the client with Local IP address (say 10.0.0.10)and a local port (4569) , the client LocalEndPoint and Remoteendpoint are always localhost ( for LocalEndPoint 127.0.0.1:4569 and  RemoteEndPoint is 127.0.0.1:50512) .<br/>Its so strange , why its creates these  incorrent Endpoints ?<br/><br/>Please help me out of this problem ! <br/><br/>Thanks ! <br/><br/><br/>Kumar <br/> <br/><br/><hr class="sig">S.KumarMon, 23 Nov 2009 14:51:22 Z2009-11-24T17:31:19Zhttp://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/69ad8016-dad3-4f13-aed5-33349d4eff04http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/69ad8016-dad3-4f13-aed5-33349d4eff04udionehttp://social.msdn.microsoft.com/Profile/en-US/?user=udioneStrange linq behavior<p>Hi, can anyone tell me why linq evaluator &quot;remembers&quot; references of all objects in expression.<br/> <br/> Code example</p> <pre>using System;<br/> using System.Collections.Generic;<br/> using System.Linq;<br/> namespace LinqTest<br/> {<br/> public class ExampleTestObject<br/> {<br/> public decimal Data { get; set; }<br/> }<br/> <br/> class Program<br/> {<br/> static void Main(string[] args)<br/> {<br/> List&lt;ExampleTestObject&gt; cCollection = new List&lt;ExampleTestObject&gt;();<br/> <br/> cCollection.Add(new ExampleTestObject() { Data = 1 });<br/> cCollection.Add(new ExampleTestObject() { Data = 2 });<br/> cCollection.Add(new ExampleTestObject() { Data = 3 });<br/> cCollection.Add(new ExampleTestObject() { Data = 4 });<br/> <br/> List&lt;Func&lt;ExampleTestObject, bool&gt;&gt; cFilters = new List&lt;Func&lt;ExampleTestObject, bool&gt;&gt;();<br/> <br/> foreach (ExampleTestObject obj in cCollection)<br/> {<br/> //ExampleTestObject oReferenced = obj;<br/> //cFilters.Add(o =&gt; o.Data == oReferenced.Data);<br/> cFilters.Add(o =&gt; o.Data == obj.Data);<br/> }<br/> <br/> ExampleTestObject oTestObject = new ExampleTestObject() { Data = 4 };<br/> foreach (Func&lt;ExampleTestObject, bool&gt; oFilter in cFilters)<br/> {<br/> Console.WriteLine(oFilter(oTestObject).ToString());<br/> }<br/> }<br/> }<br/> }<br/> <br/> </pre> <br/> This code returns for times yes, because it evaluates lambda expression by passing the last object in the foreach loop. If you replace foreach body with commented code, every thing works more intuitive:false, false, false,true. <hr class=sig> udioneTue, 24 Nov 2009 12:40:50 Z2009-11-24T16:42:11Z