|
Hello....
I am having following problem...
I want to know in run time which method of which class is running
ie.
class MyClass
{
public string GetName()
{
string className = ?;
string methodName = ?;
return className + methodName;
}
}
.......
Help quick.....
|
|
|
|
|
For a single threaded application:
class MyClass
{
public string GetName()
{
string className = "MyClass";
string methodName = "GetName";
return className + methodName;
}
}
:P
As a note "Help Me" isn't a good post subject ... everyone is asking for help and it wouldn't be very useful to have all subjects as "Help" would it. A much better idea would be to give a descriptive title, like "Determine currently running class and method".
|
|
|
|
|
Use this..
string cn = System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name;
string mn = System.Reflection.MethodBase.GetCurrentMethod().Name;
*jaans
|
|
|
|
|
i have written a program that keeps track of records in a data file and came across a small problem. writing to files for most part works fine except when i go to update entries, if the new entry is bigger than the old one it starts overwriting data ahead of the entry. if someone could give me soem advice on how i can prevent this i would very much appreciate it.
|
|
|
|
|
Text file, correct?? The only way do this is to load the entire file into memory (an array of strings works), make the changes to the in-memory copy, then write then entire file back out, overwriting what's on disk. You can even write it back out to a temporary file, then delete the original file, and rename the temp file to the original filename.
|
|
|
|
|
thats sort of what i was trying to avoid was a lot of extra work, way i once did it in c++ was i capped all my line sizes so i knew the max size i could work with but did not want this limitation in my new c# stuff, i appreciate the response and i have already thought about doing something very much like you mentioned.
|
|
|
|
|
swatgodjr wrote: way i once did it in c++ was i capped all my line sizes so i knew the max size i could work
This only works if every line is exactly the same length in the file. Then it's easy to calculate the offset and you know how much space you have left. But, if you use the default methods of writing files, then each line is not going to be the same length.
|
|
|
|
|
hi
how to save the value of a cell in row of a gridview when a click event occurs on that row.
|
|
|
|
|
may be following link help u out
http://www.codeproject.com/useritems/Drag_Drop_from_GridView.asp
P.S. try to copy paste the link
|
|
|
|
|
I have a problem creating Thread on accessing MSSQL database.
Can anyone show me how to do a series of threads in synchrony to access to the MSSQL database?
Thank you. I will very much appreciate your help.
janverge@gmail.com
|
|
|
|
|
Jan Palmer wrote: Can anyone show me how to do a series of threads in synchrony to access to the MSSQL database?
Since this would just execute each SQL command in order, why are you even using multiple threads??
|
|
|
|
|
Hi all,
Is there a way to add details to a database from a form?
I'm not really sure about the commands.
help please!
Thanks.
|
|
|
|
|
It sounds like you don't know much about databases ? What do you want to add ? tables ? columns ? rows ? A row would be an entry, as in, basic data. The web abounds with examples on how to do that, examples which you'd find much easier to follow than a few sentences offered in a forum reply.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I think u want to save records on a form to a database...
if this is the case then u should have a database containing atleast one table that has the same matching columns as the fields on your form...
and then write a code to save those fields values to your database table
|
|
|
|
|
Dear all,
I had used partial class to extend typed dataset(ex. add a method to TypedDataTable) in my windows-base applications and it works well.
But when I try it in a web services project, those extend functions which is visible within web project, but invisible to client.(I create a windows-base application then add web references point to that web project, client application will not be able to use extend function, properties etc.)
Is it true that Extending a Typed DataSet Using Partial Classes is not available in Web Services Project ?
Or is there anyway to enable it ?
Thanks for help.
|
|
|
|
|
Hi... is there any coding where I can tell a path is a folder or a file?
private void FileOrFolder(string path){
if(){//// condition is path is a folder
}
else if(){/// condition is path is a file
}
else{/// unknown condition.
}
}
|
|
|
|
|
I believe that File.Exists is one way to find out if something is a file.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
There is also Directory.Exist in System.IO it is part of File
|
|
|
|
|
in my coding format how should I put it???
if(File.Exist(path)){
}
else if(){ /// Find whether is folder?
}
else{
}
|
|
|
|
|
Assuming you don't already know it's a folder, use Directory.Exists as well.
I assumed you knew it was one or the other, in which case, File.Exists would answer the question
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
ok thanks...
if it is a folder.. I wish to know whether is there any file inside.. is there a shortest possible coding?
|
|
|
|
|
It's either File.GetAllFiles or Directory.GetAllFiles, returns a string array of file names.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
U means Directory.GetFiles?
but it only get the files. hai. think I there isn't a faster way then.. hehe
|
|
|
|
|
|
Hi,
\
I have two winform classes in question. One has a combobox. When the use picks a selection, it should display this text in the new class. I ahve this working from combobox to combobox and checkedlistbox to textbox but can't figure out combobox to textbox. Please note that the text in the combobox is a concatenated sql string from two columns, Firstname + Lastname as Fullname. I tried putting Firstname in the constructor and also lastname.
In the first form I have used
private void updatebutton2_Click(object sender, EventArgs e)
{
UpdateRole updateRole = new UpdateRole(Convert.ToInt32 (rolecomboBox.SelectedText));
updateRole.Show();
}
The second one I have said
public UpdateEmp(string Fullname)
{
this.Fullname = Fullname;
InitializeComponent();
}
public string Fullname;
private void UpdateEmp_Load(object sender, EventArgs e)
{
this.FirstnameText.SelectedText = Fullname;
}
}
Thanks. Cant figure it out.
|
|
|
|