|
You could use ildasm.exe from the .NET Framework SDK to disassemble the assembly to IL and search for "box" and "unbox". But if you're aim is to determine how ths impacts performance you should use a code profiler. There are many already available for the .NET Framework - both free and commercial - and they aren't too terribly difficult to write if you'd rather do that.
The CLR Profiler for the .NET Framework 2.0[^] is one developed at Microsoft and is used in a lot of MSDN articles as wellas in blogs like Rico Mariani's[^], who's responsible for performance in the Developer Division. Not only will it help you determine where boxing is performed but also how often and how much impact is has on your application's performance.
Also remember that any time you treat a number, struct, or enumeration as a reference type (anything that derives from System.ValueType ) boxing will occur. This is one of many great reasons for generics (similar to C++ templates) in the .NET Framework, so that you can avoid boxing like so:
ArrayList list = new ArrayList();
list.Add(1);
list.Add(2);
list.Add(3);
List<int> list = new List<int>();
list.Add(1);
list.Add(2);
list.Add(3);
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hi
I need free C# 2005 ebook.
Can give me link(s) to it, please?
Best wishes
|
|
|
|
|
|
Yup no better book than MSDN itself....
Bikash Rai
|
|
|
|
|
http://www.e-sertifika.net/ebookmicrosoft.htm
http://www.easyfilehost.com/?file=1131581215
http://www.liukun.com/puzzle/parvon/book
|
|
|
|
|
|
|
in extended columns i press tab and cursor jumjps 2 cells. How could i solve this problem?
|
|
|
|
|
Hi,
I am doing an asynchronous call as below.
Initially in the method EmployeeDetailsUpdate I had:
//ws.EmployeeDetailsUpdate(intEmployeeID, strTitle, dtBirthDate, strNotes);
as you can see below in the code.
Then I comment it out and replaced it with the async call.
The code runs fine. I just thought I get a professional look into this.
So do you think my asynchronous call is correct?
Please have a look at both the methods below.
Thanks
public void EmployeeDetailsUpdate(int intEmployeeID, string strTitle, DateTime dtBirthDate, string strNotes)
{
try
{
EmpService.Employees ws = new EmpService.Employees();
//ws.EmployeeDetailsUpdate(intEmployeeID, strTitle, dtBirthDate, strNotes);
//Asynchronous call...
AsyncCallback acb = new AsyncCallback(HandleCallbackUpdate);
ws.BeginEmployeeDetailsUpdate(intEmployeeID, strTitle, dtBirthDate, strNotes,
acb, ws);
}
catch
{
throw;
}
}
private void HandleCallbackUpdate(IAsyncResult ar)
{
try
{
EmpService.Employees ws;
ws = (EmpService.Employees)ar.AsyncState;
ws.EndEmployeeDetailsUpdate(ar);
}
catch
{
throw;
}
}
|
|
|
|
|
|
I just spotted an issue here.
This asynchronous call is on the business layer where it calls the webservice.
On the client side, when the webservice call has ended, it calls another method to populate a datagrid on the windows form.
So, since it is an async call now, before the end... is called, it sometimes calls the populatioin of the grid. So the grid gets populated before the end... call is called (Therefore incorrect population).
So should I still be using the async call here?
Hope you follow what I mean.
Thanks
|
|
|
|
|
Hi everybody, i'd like to know ('cause I'm on my first experience with c#) if it is possible with xmltextwriter, to write a new node in a specified position.
Thank you
|
|
|
|
|
Not with an XmlTextWriter , no. That is used to merely write out XML forward-only, appending elements, fragments, etc. all moving forward. If you want to open an existing XML document and add an element in a certain position use the XmlDocument to load the XML and use one of the XPath methods like SelectSingleNode to find the node you want, then either prepend or append the node you want to add like so:
class Program
{
static void Main(string[] args)
{
string xml = @"<?xml version=""1.0""?>
<root>
<child id=""one"">
<grandchild id=""a""/>
<grandchild id=""b""/>
</child>
<child id=""two"">
<grandchild id=""c""/>
<grandchild id=""d""/>
</child>
</root>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNode node = doc.DocumentElement.SelectSingleNode(@"child[@id=""two""]");
if (node != null)
{
XmlElement elem = doc.CreateElement("grandchild");
elem.Attributes.Append(doc.CreateAttribute("id"));
elem.Attributes[0].Value = "e";
node.AppendChild(elem);
}
using (XmlTextWriter writer = new XmlTextWriter(Console.Out))
{
writer.Formatting = Formatting.Indented;
doc.WriteTo(writer);
}
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you so much...in fact I was reading msdn documentation for xmlDataDocument...now I'll go trying...thanks agains
|
|
|
|
|
Be aware that the XmlDataDocument is really designed for a DataSet or similar schema. If you're XML fragment is more complex you should stick with XmlDocument .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
well, now...i have the following structure of my xml file:
- <engine_data>
<type id="Variables">
<type id="Parameters">
<type id="BreakPoint">
Now a I want to add dynamically new nodes under Variables, Parameters and BreakPoints, and for each subnode I have many properties to store, any suggestion?
|
|
|
|
|
<br />
<Engine_Data><br />
<Type id=""Variables""><br />
</Type><br />
<Type id=""Parameters""><br />
</Type><br />
<Type id=""BreakPoint""><br />
</Type><br />
</Engine_Data><br />
<br />
|
|
|
|
|
You need to change < to < and > to >, or check "Ignore HTML tags in this message" when posting SGML-derivative code like HTML and XML.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Afternoon!
Hello to everyone! My partner and I want to write in a voice conversation program, and we are making use of C#. And now, I can catch the voice from the sound card and store it in the buffer. But now I have a trouble in a big problem. “I can convey a voice file to another. But what should I do when my files pass that can make another client read-out the files and broadcast it.” (That the files are in the buffer.)
Now! In an emergency, mail to u9213120@yuntech.edu.tw
When I have received help from yours truly makes me more skillful.
Thank you for your attention!
|
|
|
|
|
Hi. I tried asking this question in ZedGraph article, but I got no answer.
I have a database with some data that I would like to be represented in graphs.
The database is like this:
exercise | weight | maxweight
squat | 100 | 120
deadlift | 120 | 130
rows | 50 | 20
<- edit: the spaces may not show correctly ->
I would like to represent the values from each exercise in graphs. but i have no idea how to do that. - i'm using the "bar-graph" from ZedGraph.
I would also like the graph to be dynamic, so that if a user inserts a new exercise, then the graph will extend with another graph.
this is what i have currently:
private void OnRenderGraph(System.Drawing.Graphics g, ZedGraph.MasterPane mPane)
{
GraphPane pane = mPane[0];
pane.Title = "Training";
pane.YAxis.Title = "Exercise";
pane.XAxis.Title = "Weight (kg)";
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlDataReader rdr = null;
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT exercise FROM training WHERE userid='"+ Page.Request.Params["userid"] +"'", conn);
rdr = cmd.ExecuteReader();
rdr.Read();
double[] x = { 50, 30, 50 };
BarItem myCurve = pane.AddBar("Weight", x, null, Color.DarkGreen);
myCurve.Bar.Fill = new Fill(Color.DarkGreen, Color.LightGreen, Color.DarkGreen, 90f);
string[] labels = { rdr["exercise"].ToString() };
pane.YAxis.TextLabels = labels;
rdr.Close();
conn.Close();
// Draw the Y tics between the labels instead of at the labels
pane.YAxis.IsTicsBetweenLabels = true;
// Set the YAxis to Text type
pane.YAxis.Type = AxisType.Text;
// Set the bar type to stack, which stacks the bars by automatically accumulating the values
pane.BarType = BarType.Stack;
// Make the bars horizontal by setting the BarBase to "Y"
pane.BarBase = BarBase.Y;
pane.AxisChange(g);
}
I am very new to C# and asp.net.
I know that i should put the rdr.Close() and conn.Close() into an exception with the rest of the sql connection, but i'm still testing.
|
|
|
|
|
Hello,
I am working on a c#.net windows project,i want to schedule some task, i need your help pls help me to find a solution for task scheduling ,pls give me a detailed solution,asps.
thanks in advance.
alex.
Alex Malayil
malayilalex@gmail.com
|
|
|
|
|
Sorry, this is the wrong place.
If you want to know why your code is not working, or how you can retrieve the full path of a file from a string, or so on and so forth, this is the best place. You are asking for a detailed solution - we don't try that here.
Try RentACoder - I'm sure Christian Graus will give a glowing recommendation.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
You mean you want to create a scheduled task using C#?
If so just create a process in C# to run Schtask.exe.
|
|
|
|
|
Hi All,
I have looked at so many threading samples my head hurts.
What I want to do is load data into a treeview control but my form hangs. Is there a way to load data into the treeview while the form loads??
I have tried some threading samples but have had issues with them. One I got to work but the form still hung (using a delegate and invoke)
Any help would be appreciated.
Thanks
|
|
|
|
|
The most common problem is accessing UI elements from another thread. This[^] article might shed some light on it. Could you post the relevant piece of code?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|