[Solved] c# HashSet init takes too long

[ad_1] If I stay away from the fact if using the HashSet is the right type for the job at hand or if your Comparer even makes sense implementing a proper GetHashCode does seem to make a huge difference. Here is an example implementation, based on an answer from Marc Gravell: class KeyWordComparer : EqualityComparer<Keyword> … Read more

[Solved] Split string by one of few delimiters? [closed]

[ad_1] Here is a generalized procedure: For a given set delimiters, use strstr to check each if it appears in the input string. As a bonus, my code below allows ‘double’ entries such as < and <>; it checks all and use the longest possible. After determining the best delimiter to use, you have a … Read more

[Solved] Write text file and open at same time

[ad_1] Is this what you are looking for? FileStream currentFileStream = null;//EDIT string tempFilePath = Directory.GetCurrentDirectory() + “\\TEMP.txt”; if (!File.Exists(tempFilePath)) { currentFileStream = File.Create(tempFilePath);//creates temp text file currentFileStream.Close();//frees the file for editing/reading }//if file does not already exist File.WriteAllText(tempFilePath, textbox1.Text);//overwrites all text in temp file //Inside your exit function: if(File.Exists(tempFilePath)) File.Delete(tempFilePath);//delete temp file 2 [ad_2] … Read more

[Solved] Number of terms in this code series? [closed]

[ad_1] It is log2 n, that is the number of binary bits (or the rank of the highest 1 bit) in the binary representation of n And you made a typo, you probably mean for(i=n,j=0 ; i>0 ; (i/=2), (j+=i)); So you start with i==n then you halve it till 0 is reached (hence the … Read more

[Solved] I want to create a dll of .cs file by code [closed]

[ad_1] You can use compiler as services – CodeDomCompiler feature to create dll/exe on the fly. How to programmatically compile code using C# compiler Compiling wiht CodeDom – Article on codeproject Alternative approach is to compile files CSC.exe command line tool to create the library. For this you need to launch new process with appropriate … Read more

[Solved] C language & | ~ > [closed]

[ad_1] This is fundamental and so there are many potential applications, but here’s a specific industrial example: Suppose you’re sending a bunch of command and/or status info between devices. To avoid wasting bandwidth (particularly if you’re using a slower type of connection such an old 9-pin serial connection, which are still used on industrial devices), … Read more

[Solved] WPF binding to custom class with observable collection

[ad_1] It sounds like you haven’t assigned your DataContext. Below is a brief example. Assuming your custom class looks something like this: CODE: public class Foo { private ObservableCollection<string> _names; public ObservableCollection<string> Names { get{ return _names;} set { _names = value; } } } and your XAML looks like XAML: <ListBox Name=”lstNames” ItemsSource=”{Binding Names}”/> … Read more

[Solved] Console window disappear immediately

[ad_1] You need to add the following line after your code: Console.ReadKey(); This will prevent the console from executing the next line until you press any key. In your case, it will simply finish running the code. 1 [ad_2] solved Console window disappear immediately

[Solved] WCF CallBack implementation [closed]

[ad_1] I can give you one big advantage. We have an application that involves a client (WPF) and a Windows service. Normally the client calls the service (via WCF) to retrieve and/or save data etc. But, there are times we want the service to send the client a message, to notify the client it needs … Read more

[Solved] Segmentation fault 11 because of a 40 MB array in C

[ad_1] Because you’re creating that as an automatic variable, it will go on the stack. The stack size is not very large. A general rule of thumb is for any objects larger than a few KBs, always dynamically allocate them on the heap using malloc() (or new for C++). Your program is crashing because the … Read more

[Solved] Recursive scan of folder tree C [closed]

[ad_1] You could take a look at Glib, there are some file utilities that can be helpful here. More specifically, you can use g_dir_open function on every file in a directory. If this function sets the GError**error pointer non-null, then you have tried to open a file, otherwise you’ve just parsed into a subdir… Your … Read more

[Solved] how to clearly design these two class? [closed]

[ad_1] It’s a question of design. Weapon has the field addPower, but IWeapon does not. This would imply, that not all weapons (not all classes that implement IWeapon) do add power to the character. So you can’t use this property, if the interface doesn’t define it. (Casting an interface to an implementing class defies the … Read more