Answer Questions
Mrzev Replacing '\r' in a string: .NET 1.1
Hi All, I have an application that takes input and splits it on the '\n' character. Every carriage return however is a combination of '\r\n', therefore I am left with stray '\r' characters. I wish to remove these characters with the minimum of fuss in the .Net framework 1.1! I have already formulated a way to do this using stringbuilder.replace, however is there an easer (and more efficient) way as I will be applying this to millions of strings. Thanks Chris why dont you just replace \r with String.Empty Example... string myString = "hi\r\n my name is bob"; myString = myString.Replace("\r", String.Empty); string[] arraySplitString = myString.Split(new string[] {"\n"}, StringSp ...Show All
dr.acv Fire events
I am new to events so i need a ltlle help. I would like to raise a event every two seconds. When the event is raised I whant to run two methods. if you could just outline how to do this it would be helpfuly. to raise events every 2 seconds, you need to use a timer class/control, set the interval to 2000 milliseconds and then fire the event. about events: http://msdn2.microsoft.com/en-us/library/awbftdfh.aspx I moved to C# after a little experience in Java, so I had a hard time with events. I looked at lots of examples and tried using them many times until I got the hang of them (I know I still have much to learn). Here is an example of how you could do it: System.Windows.Forms.Time ...Show All
David_Reynolds Bind folder structure to a Treeview
Hi Please transilate the following code for me to C#: This function collects and displays the files in a specified folder as hypelinks on a webpage. I would like to attach this to a TreeView control on an aspx webpage.Thanks in advance.I would also like to have the file list as hyperlinks ,so that the files opens when clicked on. Function ShowOfferFileList(folderspec) dim FileExtension dim FilePath Dim fso, f, f1, fc, strList dim i Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(folderspec) Set fc = f.Files For Each f1 in fc FilePath = cstr(f1.name) FileExtension = GetExtension(FilePath) 'FileExtension = mid(FilePath, len(FilePath) - 3, 3) 'FileExtension = mid(FilePath, 1, 3) if ...Show All
PareshGheewala C# compiler BUG - const delegate assignment within a structure definition
There is a bug in the C# complirer which Visual Studio crashing. The bug happends when writing a const delegate assignment within the a structure. for example: public struct Temp { private const Action<bool> Foo = delegate() { return false; }; } I searched everywhere to find a link for a bug report. I even called the support team. Unfortunately I couldn't do it online because the the ActiveX control on the web site failed to locate the product id. I even tried it manually but it gives me "Invalid produc id" error. I'm using VS2005 on Vista. FYI, replacing the const with static will solve the problem. Thanks, /Ali (mailto: alij@alcor.concordia.ca ) True! Though VS can "decid ...Show All
mirolslaw VS 2005: "Key not valid for use in specified state"
Hi all- I'm running VS 2005 final release version. I have a solution with two projects in it; an ASP.NET website in C# and a VB project which is my data access layer. Yesterday, this code was working fine. I can compile and run the solution, and all the code works. But when I try to access or add a new datasource through the VS 2005 Data Sources Explorer, I get a popup which says: "An unexpected error has occurred. Error message: key not valid for use in specified state." This message pops up after I select database as the source of my new datasource. The wizard does NOT fail if I use a Web Service as my new datasource. Any ideas on what is happening, and how to clear up the problem ...Show All
Dileep Agarwal how to call contructor of base class from constructor of inherit class
hi, there is a base class that has no constructors with zero arguments, like public baseclass(int param1){ something(); } there is a class that inherits from that one when i try to call constructor from derivated class it tells me something about base class does not have constructor with zero arguments how do i call the constructor of base class i tried something like base (intvalue), but it does not work, also tried something like base.baseclass(someint), did not work either. how to call constructor from base if base has no 'zero arguments' constructor tnx hi, It's quite nature that the base class dont have a constructor with no param for you to invoke. But ...Show All
Big5824 Window Hook?
Hello, I know you can create window, message, mouse hooks and such but is it possible to do some sort of window hook that can notify my program whenever a window is moved or created See This: http://www.codeproject.com/csharp/globalsystemhook.asp Best Regards, Rizwan Thanks, I looked through it but i'm still not sure which hook I need to use for what i'm trying to achieve. This tutorial seems to mainly focus on mouse/keyboard hooks. Are there any examples more similar to what i'm trying to do Thanks, from what i've read, a window hook isn't possible using C# alone. It seems to require creating a DLL in C++. I've found a very good example similar to what ...Show All
mogens While Loop Optimization
I have a while loop that tests the value of (A*B > SomeNumber). This while loop is repeated at the very least several million times so code efficency is very importatant. A and B do not change while the loop is running. My question is would it be more efficent to first get the product of A and B and then test that variable against SomeNumber, or does it not matter Any other tips for optimization would be helpful too, thanks in advance. I appreciate your help, although I don't think using NGen will help my program. This is a common optimization target named "Loop Invariant Hoisting Optimization". I know the C++ backend optimizer was good at doing this; n ...Show All
JoeWood How to use DllImport with c++ functions that take a function pointer as an argument?
I'm trying to understand how dll importing in c# works. I've managed to get it working for function F1 shown below, however I want to extend this to a function of type F2, which takes a function pointer as an argument I've look at the example on MSDN, but it is too dissimilar from what i am trying to do and I don't really understand it. Can someone tell me the c# code that will enable me to import the function F2 into my c# program, or point me to a a more basic tutorial than the MSDN help site, because I really didn't find it useful in helping me solve this particular problem. This is the .cpp file that i compile into a dll which my c# program then uses. I have successfully imported F1, but all attempts to import F2 have failed... extern ...Show All
ChandraDevaraj reuse vs code editor window
Hi, I do not know if this is the right forum for my question, but I ask anyway. Is there a way to reuse the vs code editor window in applications of mine (like I can use a visio control), so I can profit from intellisense etc.. Thanks in advance Alexander There's no documented way of using this control. There are lots of other syntax-colour editors around though. Hi, Alexander, maybe ,you can take a look into sharp develop code source.. the code editor can be reuse, it maybe will give you something you wanted. ...Show All
J. Wind How can I retrieve advanced file information?
...Like the Title of a song, the Bitrate, Album, etc. Thanks, I tried doing that, but it didn't help. theArtist is just a string variable declaration,: string theArtist you are creating a variable called "theArtist" of type string. Copy and paste the code and run it (of course change the path to the mp3 file) and it will run. I'm doing it right now also, works fine. I will see how to get the bitrate of the mp3 file, but dont think it is held in the header of the MP3 (IDTag v1) file but unsure But, it still doesn't appear! label1.Text = theTagInfo.Substring(#, #).Trim(); Nothing appears! It builds though... What does this do: ..... .Contains("TAG")) ...Show All
Han Duong Process.start() how to
Hi All, I'm using process.start() to execute msbuild.exe. Is there any properties or method that I could set or call to wait until it completely finished before the next line of code get executed Best Regards, When I remove theProcess.Start(); line then it throws, "No process is associated with this object." Exception. Here is the stack trace at System.Diagnostics.Process.EnsureState(State state) at System.Diagnostics.Process.EnsureState(State state) at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited) at System.Diagnostics.Process.WaitForExit(Int32 milliseconds) at System.Diagnostics.Process.WaitForExit() at Project_Runner.Class1.Test(String path) ...Show All
Hassaan Nasie C# Book Recommendations
This sticky here will be used for people to post their C# book recommendations. It will help us keep the forum a bit cleaner than making several topics about book recommendations and also helps everything to be in 1 "spot" and alot of people can see the book recommendations that you have given everyone else in this topic. So please, feel free to post your book recommendations here for developing in C#! :-) If possible, include any links where the person would be able to obtain the book from, and it's ISBN number which would be a big help to everyone! I am also a big fan of Programming C# (O'Reilly). I can't say that I have ever come across a book from O'Reilly that I didn't really like and believe me I have a lot of them. ...Show All
ptaylor "Could not run the '...CSharpAddDataset.vsz' wizard."
I'm now getting this sudden and unexpected "Could not run the 'C:\......\LocalProjectItems\..CSharpAddDataset.vsz' wizard whenever attempting to add a new DataSet to my project. I checked, and this file is indeed missing. Has anyone experienced this before in VS.NET 2003 Enterprise Developer OK, I found the file in a parent folder, so it is there, but it seems as though the IDE is incorrectly looking in another place for it or some other cause is generating this error. I can open an existing typed DataSet OK, but it's when I want to add a new one that I get the error. I also checked the .\data\data.vsdir file and it has an entry for ..\..\CSharpAddDataSet.vsz Yeah, I've already tried moving directories, files, ...Show All
Pranav Sanghadia sumary not visible in other projects
Hi! I write a .dll file that contains a class, his methods has coments about sumary, parameters and return. If i use this class in the same project, i view perfectly this comments in the tooltips, but if i put this dll in another project ... i don't view the comments in the tooltips of code insight. From the object browser i can't view the comments either. What's the problem Regards. Hello V.Tortola - I moved your question here as this seems to pertain more to how the IDE works. Thanks - This is most likely because the project isn't set to build an XML documentation file. Take a look at this walkthrough about using XML doc comments to document a component: http://cyrino.members.winisp.net/9112006/ ...Show All
