|
Exactly, and questions like yours will always be welcome in The Code Project forums
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Man it worked great but could you explain what is the use with "D" i did not know what did it do.
|
|
|
|
|
some data types (such as int) have the option to overload the ToString method and provide a string containing format information. 'D' followed by a number ensures that the string contains as many preceding zeros as dictated by the number. have a look here[^] for more information
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I am using Relection to get Methods from an Assembly.
I want to display the local Variable names in a method.
I have a test method called Test.
public void Test()
{
string myString = string.Empty;
int myInt = 0;
}
So I am using the following code:
MethodInfo[] methodInfo = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
List<MethodInfo> methods= new List<MethodInfo>(methodInfo);
foreach (MethodInfo method in methods)
{
MethodBody methodBody = method.GetMethodBody();
IList<LocalVariableInfo> localVariables = methodBody.LocalVariables;
}
My problem is, even if I loop through the localVariables collection, I am not able to get the name of the variables of Test Method.
Kindly let me know how do I get the variable names.
Thanks in Advance.
|
|
|
|
|
Hi,
AFAIK local variables are not available in the meta data, except for the method's parameters.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Correct. Reflection only exposes the interface, not the implimentation.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Agreed, I know that,
but I could see the variable names in the method in ildasm so I thought there might be a way to get those. I know ildasm is DISASSEMBLER but took a chance.
Thanks for reply,
Aniruddha
|
|
|
|
|
Hi,
forget Reflector, it won't tell you about locals. You need either the source files or, maybe, the PDB file.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Anir1982 wrote: Kindly let me know how do I get the variable names.
You can't and that is the end of it. It would require that reflection exposes the implimentation of the method rather than the interface.
What use would it be if you could in the long run? You cannot [or should not] be able to change the state of internal variables. Local variables only have scope within the life of a single call to the method. How or when would you be able to constructively use the instance or local variables of a class or method?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
How Can I Select any Row In DataGridVeiw
|
|
|
|
|
example :
dataGridView1.Rows[3].Selected = true;
|
|
|
|
|
Thanks But How Can I MOve The ScrollBar To That Row
|
|
|
|
|
dataGridView1.FirstDisplayedScrollingRowIndex = 3; // set the index of row here..
|
|
|
|
|
I Am Greatfull.
Thanks Again
|
|
|
|
|
Hello!
I have a very simple question. If I want to create an event to my class I can use the EventHandler delegate like this:
public event EventHandler OnLog;
But the EventHandler delegate takes two arguments (the sender and an EventArgs object). If I don't want to have those arguments in my event, is there any other event handler delegate that takes zero arguments or so, or do I have to create the delegate myself?
Regards
|
|
|
|
|
Just use:
if(OnLog != null)
{
OnLog(null, EventArgs.Empty);
}
|
|
|
|
|
or define your own delegate.
or use an Action<type> so you can have exactly one argument with a type you choose.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi all,
I have the following
sda.fill(ds);
string xmlDs = ds.GetXml();
WebRequest req = null;
WebResponse rsp = null;
try
{
string fileName = xmlDs;
string uri = "http://www.website.com/Pages/CongratulationsListener.aspx";
req = WebRequest.Create(uri);
//req.Proxy = WebProxy.GetDefaultProxy(); // Enable if using proxy
req.Method = "POST"; // Post method
req.ContentType = "text/xml"; // content type
// Wrap the request stream with a text-based writer
StreamWriter writer = new StreamWriter(req.GetRequestStream());
// Write the XML text into the stream
writer.WriteLine(fileName);
writer.Close();
// Send the data to the webserver
// SendRequest(uri);
rsp = req.GetResponse();
rsp.Close();
}
catch (WebException webEx)
{
}
catch (Exception ex)
{
}
finally
{
if (req != null) req.GetRequestStream().Close();
if (rsp != null) rsp.GetResponseStream().Close();
}
My listner page (CongratulationsListener.aspx) doesnt seem to get any Xml data?
Can any one advice please?
Thank you in advance.
|
|
|
|
|
How I Show System Date And Time In Label
I Perform This task Bt Not Found Actual Result
I USe This Code For Date And Time
Using System.Diagnostics;
Load_Form
DateTime dt = DateTime.Now;
label1.Text = dt.ToShortTimeString();
-------------------------------------
|
|
|
|
|
Bad subject line.
DateTime.Now does gives the system time. What is it giving in your case?
|
|
|
|
|
It given me Sytem Time bt it not change when my system time change.
|
|
|
|
|
Of course it doesn't you've not told it to! All you've done is take the current date/time and converted it to text to display in a label. If you want it to update, you need to tell it to - computers are not mind-readers!
Set up a timer, make it poll every second, and in the Tick event update your label to the current date/time just as you did in your original code.
|
|
|
|
|
yes you right..
i take timer and set it interval = 1oo
now how i implement this ??
|
|
|
|