|
Hi, where do I insert this code?
|
|
|
|
|
hi
whereever you want !!!!!!!!
like when load the data, on button pressed
Tamimi - Code
|
|
|
|
|
I have an XmlNodeList and I just want to reverse the order of it. I have to keep it as an XmlNodeList because my repeater control (which I bind to it) depends on that.
/\ |_ E X E GG
|
|
|
|
|
Since the XPath function reverse is only for XPath 2.0, I can think of only two ways to do this:
1. Put your XML into a DataSet and use a DataView to tell it to sort in reverse order.
2. Use an XPathNodeIterator .
Option 2 is kind of difficult. Basically, instead of using an XmlDocument , you use an XPathDocument object to represent your XML. Then, you create an XPathNavigator from the document or from the node in the document that you want to start from. Use the navigator to Compile an XPathExpression object. Call AddSort on the XPathExpression to tell it to sort the nodes in reverse order (this is similar to how you would sort in an XSLT document). Then you can call the Evaluate method on the XPathNavigator to get an XPathNodeIterator , which you can bind to. The code really isn't that long, it just takes a while to figure out.
|
|
|
|
|
how can i made me application to have an intercactive interface like nero interfce ?
|
|
|
|
|
be creative
Tamimi - Code
|
|
|
|
|
Sir, i need help to make a chat room in C#.net. Kindly can you provide me any chat application source code.
|
|
|
|
|
|
All,
Are there any conditional defines for the /unsafe compiler switch? I have some code that I've written two versions for, one usafe (and much faster) and the other all "safe" code.
I now want to wrap the code in #if / #else / #endif blocks but need a "internal" conditional define that will select based on the presence of the /unsafe compiler switch.
Or... where can I get a list of "all" the VS.2005 C# "internal" conditional defines?
Thanks,
-Vino Rodrigues
|
|
|
|
|
Directives:
http://msdn2.microsoft.com/en-us/library/ed8yd1ha.aspx
You can create your own DEFINE and set it accordingly.
example: csc CondMethod.cs tracetest.cs /d:DEBUG
|
|
|
|
|
Thanks mate.
Know that one already.
I was hoping for a pre-defined (like MS code used "WINNT" or "WINCE") or an alternative method to "know" when /unsafe switch is on.
-Vino
|
|
|
|
|
Wouldn't that just be placed in the MSBUILD? There are several sections for each development target.
|
|
|
|
|
You might be able to work something out with this:
Conditional Attribute in C# compared to #if #endif
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=420
|
|
|
|
|
Hi All,
I have the following:
public struct sFileListStruct
{
public String sFileName;
public DateTime dFileTime;
}
I am developing an application that backs newly modified files up to the server. I want to save bandwidth, and the route that I have chosen is when the application copies a file onto the server, it will add an entry into an arraylist. At the end of the operation the arraylist is written to a file. (Serialized).
When the application starts, it reads the file and populates the arraylist with sFileListStruct. These are the files that have been backed up already. Next, I perform a file search and populate another ArrayList. This second ArrayList contains all the current files.
I want to compare the filename's and then look at the modification time for each file. I basically have something such as
foreach (sFileListStruct sCurrentFile in aAllFilesArrayList)
{
// Do some code in here
}
Now, what I have tried inside of the foreach is to do this:
if (aFilesCopiedArrayList.IndexOf(sCurrentFile) != -1)
{
// It's a new file, or the modification date has changed, do something here
}
I have also tried using sFilesCopiedArrayList.Contains(). They are incredibly slow. There are around 1,000 files that it is comparing, and it takes 60 seconds or more to do a comparison of them using either of those methods (This is a 2.6GHZ dual core machine). What I have winded up doing, which cuts that time down to about 10 seconds is actually putting a foreach within a foreach
foreach (sFileListStruct sCurrentFile in aAllFilesArrayList)
{
foreach (sFileListStruct sOldFile in aOldFilesArrayList)
{
if ((sOldFile.sFileName == sCurrentFile.sFileName) && (sCurrentFile.dFileTime > sOldFile.dFileTime)
{
// copy and update...
}
}
}
That appears to be a lot quicker than using IndexOf or Contains. I am wondering if anyone knows why, or is there some other way that I can check one ArrayList's contents against another ArrayList's contents quicker? I am just trying to do it the proper way and the way that will allow it to run the quickest.
TIA
|
|
|
|
|
Use a Hashtable with the filename as key. That should make it considerably faster to locate the items.
---
b { font-weight: normal; }
|
|
|
|
|
What Guffa said. If you still want to continue with your approach, you could try
1. Does sFileListStruct have to be a struct/code>? Things would be much faster if it's a <code>class instead.
2. converting the ArrayList to List<sFileListStruct>. This will work only if you're using .NET 2.0. This saves the unboxing cost when you read the struct out of the list.
3. Overriding Equals in your struct should help things too. I've read that the default implementation of Equals, which is what IndexOf uses, uses reflection to compare field values.
|
|
|
|
|
Hi i am stumped on how to insert characters into a string so it can display correctly. for instance i am wanting to format a string (ex "19999"). To be displayed as 199.99 (to show a price of $199.99 instead of $19,999). Also to go a bit further i would if the price did reach in the thousands (ex 121499) i would need it to show as 1,214.99. I've looked for some format property but i couldn't find anything
Thanks in advance
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Since you constantly want to change 123456 into 1,234.56 then I suggest converting the string into a decimal first, then divide it by 100 and display it.
You can use the {0:c} currency formatting to display the '$', the ',' and '.'
Here's[^] a good article on string formatting in C# just in case you need it.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia
|
|
|
|
|
Try this:
string output = (value / 100.0).ToString('N');
the 'N' style gives your number to two decimal places and comma seperates the thousands.
Regards,
Rob Philpott.
|
|
|
|
|
hi this is my code for get CPU ID :
string cpuInfo = String.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == String.Empty)
{ // only return cpuInfo from first CPU
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
}
}
return cpuInfo;
but in my system, it is not working correctly(and why in another computer it worked correctly ?)
the error that was shown me : Object reference not set to an instance of an object.
How to solve problem ?
thanks .
|
|
|
|
|
The ProcessorId isn't what you think it is. It's not serial number that can be used for some kind of compy protection. It's a field that describes the capabilities of the processor:
ProcessorId
Data type: string
Access type: Read-only
Processor information that describes the processor features. For an x86 class CPU, the field format depends on the processor support of the CPUID instruction. If the instruction is supported, the property contains 2 (two) DWORD formatted values. The first is an offset of 08h-0Bh, which is the EAX value that a CPUID instruction returns with input EAX set to 1. The second is an offset of 0Ch-0Fh, which is the EDX value that the instruction returns. Only the first two bytes of the property are significant and contain the contents of the DX register at CPU reset???all others are set to 0 (zero), and the contents are in DWORD format.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi,
I work on a computer that is part of a network and uses proxy to connect to net. I cant connect to servers outside my proxy with simple ConnectTo code. I need to know how to make my requests go through proxy. eg,
serverTcpConnection = new TcpClient(popServer, port);
does not work.
Thanx.
|
|
|
|
|
You cannot bypass the proxy. Either the administrator of the proxy machine has to open up the port for you, or, you have to tunnel it through some port which the proxy keeps open. Typically, proxies keep port 80 for HTTP open. You could write a webservice that runs on a machine that has access to the port you want and then simply have your client call the webservice instead.
|
|
|
|
|
I've derived my own GradientListView class from the ListView control to try and draw a gradient background. I'm able to draw the gradient background just fine by overriding the OnPaintBackground event, but the ListView items no longer appear in the ListView. Is it an all or nothing deal?....Do I need to handle all the painting events if I override one of them? If I comment out the SetStyle command in the constructor the ListView shows the items correctly, but obviously without the gradient background.
public GradientListView()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
ControlStyles.DoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
}
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
{
PaintRectangle(this.ClientRectangle, this.BackColor, Color.Black, pevent.Graphics);
}
protected void PaintRectangle(Rectangle Rect, Color RectColor, Color RectBorderColor, Graphics g)
{
Pen LinePen = new Pen(RectBorderColor, 10);
g.DrawRectangle(LinePen, new Rectangle(Rect.X, Rect.Y, Rect.Width - 1, Rect.Height - 1));
LinePen.Dispose();
Rect = new Rectangle(Rect.X + 1, Rect.Y + 1, Rect.Width - 2, Rect.Height - 2);
SolidBrush bgBrush = new SolidBrush(RectColor);
g.FillRectangle(bgBrush, Rect);
bgBrush.Dispose();
LinearGradientBrush brush;
Rectangle BottomRect;
BottomRect = new Rectangle(Rect.X, Rect.Height-((int)(Rect.Height / 3)), Rect.Width, Rect.Height / 3);
brush = new LinearGradientBrush(
new Point(BottomRect.Width / 2, BottomRect.Top - 1),
new Point(BottomRect.Width / 2, BottomRect.Bottom),
RectColor,
ControlPaint.Dark(RectColor));
g.FillRectangle(brush, BottomRect);
brush.Dispose();
}
|
|
|
|
|
If you have the control set to OwnerDraw then it means you will draw everything.
Have no fear, though, since you can override Paint and then just call base.Paint().
See if that corrects the drawing problem.
As to your user name.....BRILLIANT!
|
|
|
|