|
I just compiled this code in C# 1.1 and it compiled and ran okay.
class A
{
public static void Main()
{
System.Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
}
}
|
|
|
|
|
Thanks Nishant. It works now.
private static Type thisClassType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
private static readonly ILog logger = LogManager.GetLogger(thisClassType);
I beleive System.Reflection comes from System.dll
Pankaj
|
|
|
|
|
pankazmittal wrote: I beleive System.Reflection comes from System.dll
MethodBase is in mscorlib.dll
|
|
|
|
|
|
I have a class in C# that inherits from PrintDocument, generates a document and there is no problem to preview it and print it in .NET, but the printing functionality of the component to which this class belongs needs to be called from VB6 too, how is it possible to preview and print the PrintDocument in VB6??
Thanks in advance
Isaac B
|
|
|
|
|
Hi ...
I only want to remove the FIRST "ma" but it appears that i must use a string method on a copy of a StringBuilder variable in order to execute the Remove method of StringBuilder.
string pat = "ma";
string dictWord = "Wrestlemamania";
StringBuilder w = new StringBuilder();
w.Length = 0
w.Append(dictWord);
int result = dictWord.IndexOf(pat); // Why must i look at a STRING variable
dictWord = dictWord.Remove(result, 2); // in order to do THIS
w.Remove(result, 2); // using a StringBuilder variable?
I can't find the equivalent "IndexOf" in the StringBuilder methods. How would this be done using StringBuilder? What am i missing?
Thanks.
|
|
|
|
|
You're doing this the hard way. All you need to do is find the position of the first occurance of "ma" in the string, then call the Remove method on that string, supplying the starting position and how many characters to remove, which will return a new string.
string pat = "ma";
string dictWord = "Wrestlemamania";
int pos = dictWord.IndexOf( pat );
dictWord = dictWord.Remove( pos, pat.Length );
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes ... you are correct, however, the question was not whether it could be done with STRINGSs, but rather how to do it with STRINGBUILDER. In fact, i am currently using STRINGs ... precisely as you describe.
The problem occurs when you have hundreds of thousands of these things to do ... performance becomes important ... and i wondered if i could speed things up if i could avoid CONSTRUCTING the resulting millions of intermediate strings needed in the complete solution.
IMHO, the need to create a STRING negates most of the value associated with using STRINGBUILDER ... in fact, it makes matters worse.
I only showed part of the problem ... the part that was perplexing: the lack of an "IndexOf" method for STRINGBUILDER.
|
|
|
|
|
IceWater42 wrote: the part that was perplexing: the lack of an "IndexOf" method for STRINGBUILDER.
There is no "IndexOf" because a StringBuilder treats the string as an array of characters. There is no way to tell what the first occurance of a string is because you can't compare a string to an array of characters. It could be done with custom coding to comparision, but the performance hit in this code would more than likely be worse than rebuilding the string using string objects.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
StringBuilder is for building strings, not examining them.
Instead of string manipulation like this, you might want to look at System.Text.RegularExpressions
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
Let's say I have an application running with a button on it. When I press that button, it launches an application (say MS Paint for example). But I want that application to be a child of my application (if you press minimize, for instance, the MS paint would be minimized as well).
Is there a way of doing this in C#?
|
|
|
|
|
Like an MDI Child?
Windows doesn't support it.
Now, if that application were to be launched as a seperate process without any care if it shows up in it's own normal window, then you could keep track of the process, get it's main window handle and send the appropriate Window messages to it to get it to minimize and restore itself when your app is minimized.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 12:41 Friday 16th December, 2005
|
|
|
|
|
In C# 2005 if you put an ErrorProvider onto a form, between the form's controls' (eg. a TextBox) properties an "Error on errorProvider1" item appears. How does this work and how can I make my own class to behave like an ErrorProvider?
|
|
|
|
|
The ErrorProvider works by implementing the IExtenderProvider interface. You can find MSDN documentation on the IExenderProvider interface here[^]. Also, I would recommend James T. Johnson's article[^] here on CP covering the topic as well.
|
|
|
|
|
Hi all,
Just started looking at C# (been using Java for a while now) but is it possible to access a corba server using a C# client, the server is using visibroker for java. Could I generate the stubs for the client using the C++ version of visibroker and use them?
Cheers...
|
|
|
|
|
IF you've got c++ dll's you can p/invoke any function/methods they provide.
|
|
|
|
|
|
Hello.., i'm working on a project, where i have a dataGridView, that get's it's data from at database (Access).., that works...
In the database (MusicCollection), there are several column's, ex: "Type", that contains "CD", "LP", "Single" etc.
In the Properties for ComboBox1, i have set the dataSource to "MusicCollection" and the displayMember to "Type"
That works, but if there are 100 CD's in the database, "CD" appears 100 times in the combobox...., and i only want 1 occurence for each Type...., like the sql-statement: SELECT DISTINCT Type FROM MusicCollection
I would like to use a sql-statement, but i don't know, where to put it...
I use Visual Studio 2005 Express.
(i'm sorry about my pore english )
I hope, that someone can help me.
Helge
|
|
|
|
|
this.DropDownList1.Items.Clear();
this.DropDownList1.datasource:=dataset.tables["MusicCollection"];
this.DropDownList1.databind();
each time u fill combobox first empty then set datasource cuz to not duplicate datas;
hope helps
|
|
|
|
|
Hello, thank you for fast reply..., but i don't understand:
then set datasource cuz to not duplicate datas
Is it something i should do in properties for ComboBox1...???
Helge
|
|
|
|
|
just pointing out that you need to do this *each* time
this.DropDownList1.Items.Clear();
this.DropDownList1.datasource:=dataset.tables["MusicCollection"];
regards,
g00fy
|
|
|
|
|
A goal is:
if u load your form or you make any event example by clicking button or any other enevt dropdownlis fills again. this is multi-dupliacted data.
every time clear combobox then fill it again from ur table?
hope i was clear???
dropdownlost.items.clear();
dropdownlost.datasource.dataset["TableName"];
dropdownlost.DataBind();
-- modified at 2:45 Monday 19th December, 2005
|
|
|
|
|
I have a paremeter in an xml file that can contain one of a dozen discrete, non contigious integers. To enforce the limited selection I've defined them as follows in the xsd, and built a wrapper class using the xsd tool.
<code>
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:enumeration value="123"/>
......
</xs:restriction>
</xs:simpleType>
</code>
<code>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="TheNameSpace")]
public enum EnumType
{
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("123")]
Item123,
}
</code>
I can read/write the xml normally without problem. The issue comes when I want to reassign a value of EnumType, and use it later in the session.
<code>
xmlClassObject.EnumTypeValue = (EnumType)123;</code>
This assigns the value to the enum, and will save properly. The problem is that as shown in the debugger or created using ToString(), the value loaded from the file is "Item123", while the value I set in code is "123". Is this a bug in MSes code, or should I be setting the value in a different method? I tried creating the string "Item123" and assigning that, but the cast failed.
-- modified at 10:13 Friday 16th December, 2005
Is there a way I can use the code tags, and still have my XML survive?
|
|
|
|
|
Dear All,
I have a directory in E drive, which I want to share and allow full control to aspnet via C# programming.
I need simple code for it.
With Regards
Manoj
|
|
|
|
|
You can make a call to the net command line application
net share sharename=c:\folderToShare
You can call this from C# using
System.Diagnostics.Process.Start ("net share myShareName=c:\\folderToShare");
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|