|
Why don't u google[^] it?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
my application host server has a virtual memory and physical memory limit set (150mb for virtual, 100mb for physical) in iis application pool, now my application keeps getting recycled. event viewer says "process x from application pool y has reached its virtual memory limit."
how do i get around this?, ive used performance monitor to monitor my application, it doesnt seem to leak any memory.
any ideas?
|
|
|
|
|
I have a string, oldWord, that contains exactly 1 space SOMEWHERE in it. I want to generate 26 copies of that word with the space being converted to a letter, 'a' through 'z'.
I tried this:
string oldWord;
string[] newWord;
...
for (int c = 0; c < 26; c++)
{
newWord[c] = oldWord.Replace(' ', 'a'+c );
}
The compiler complains about the parameter, 'a'+c , as being an "invalid char", as you probably expected. I've tried lots of different combinations, to no avail. Would you please tell me how i can code that parameter so i get the expected result?
Thank you.
|
|
|
|
|
Hi!
Do it like this:
newWord[c] = oldWord.Replace(' ', (Char)((int)'a'+c));
It converts the 'a' to a value, add the additional value and convert it back to a character.
Marcel Erz
|
|
|
|
|
Hi,
You can also try this ...
<br />
string oldWord = "Hello Welcome";<br />
string newWord = "";<br />
for (int c = 0; c < 26; c++)<br />
{<br />
int newchar = (int)'a'+c;<br />
newWord += oldWord.Replace(' ', (char)newchar );<br />
}<br />
System.Diagnostics.Debug.WriteLine(newWord);<br />
Result:
<br />
"HelloaWelcomeHellobWelcomeHellocWelcomeHellodWelcomeHelloeWelcomeHellofWelcomeHellogWelcomeHellohWelcomeHelloiWelcomeHellojWelcomeHellokWelcomeHellolWelcomeHellomWelcomeHellonWelcomeHellooWelcomeHellopWelcomeHelloqWelcomeHellorWelcomeHellosWelcomeHellotWelcomeHellouWelcomeHellovWelcomeHellowWelcomeHelloxWelcomeHelloyWelcomeHellozWelcome"<br />
Happy Programming!!!
Regards,
P.Anbuselvan
Sr.Software Engineer
Hyderabad
|
|
|
|
|
Here is another suggestion: Why not use a character counter:
int i = 0;
for (char c = 'a'; c <= 'z'; c++) newWord[i++] = oldWord.Replace(' ', c);
---
b { font-weight: normal; }
|
|
|
|
|
Thank you ALL for the excellent suggestions. I tried the 1st 2 suggestions before the 3rd was made ... they both worked great ... PLUS i got the added benefit of learning how to 'cast'.
Thanks again,
|
|
|
|
|
Hi All
I need to find the date of the day before today and create string of this date.
I cant find the date of today and make less 1 from the date because i could get 0 in date (if i try to find the yesterday of 1.1.2005 i need to get 31.12.2004 ).
I sure that there is some build in method to do it -
Some one can help me ?
Thanks.
|
|
|
|
|
DateTime.Now.AddDays(-1);
|
|
|
|
|
Hi!
Just use the methode AddDays from the DateTime-class and give as parameter a negative value.
DateTime loDate = new DateTime();
loDate = DateTime.Now;
loDate = loDate.AddDays(-1);
MessageBox.Show(loDate.ToString());
other samples:
loDate = loDate.AddDays(-5); // Subtract 5 days
loDate = loDate.AddMonths(-3); // Subtract 3 months
Marcel Erz
|
|
|
|
|
Try using
DateTime dt = DateTime.Now ;
dt = dt.Subtract(new TimeSpan(1,0,0,0,0)) ;
Console.WriteLine(dt.ToShortDateString()) ;
Hope this helps.
Bikash Rai
|
|
|
|
|
What is the difference between Singleton implemented using static GetInstance() method and having a Class with all Public Static methods. Is scenario#2 a Singleton class? Please let me know the differences between these two approaches.
1)-----------------
public class SealedClass
{
private static SealedClass _class = new SealedClass();
private SealedClass()
{}
public static SealedClass GetInstance
{
get
{
return _class;
}
}
}
--------------------------------------
2) public class StaticClass
{
public static string GetName()
{
return "Shubho";
}
public static string GetAddress()
{
return "Shubho";
}
}
|
|
|
|
|
Interesting question.
According to the GoF, the purpose of a singleton is to "ensure a class has only one instance, and provide a global point of access to it." Your second example has no instance, its just a collection of static methods and hence we couldn't get a reference to it.
Microsoft has a best practice with regard to singletons - they say it should be implemented as follows - a thread safe lazy implementation
public class Singleton
{
private Singleton() {}
private static volatile Singleton _singleton;
private static object _lock = new object();
public static Singleton Value
{
get
{
if (_singleton == null)
{
lock(_lock);
{
if (_singleton == null) _singleton = new Singleton();
}
}
return _singleton;
}
}
}
Regards,
Rob Philpott.
|
|
|
|
|
Sos... I'm creating a graphical shapes that represents "cut off" pieces of a roll of material.
Problem: I need a algorithm that applies optimal control on these shapes to graphically show how a roll of material can be cut to utilise it's full potential and also show the wastage factor.
Can anyone help. pa-lease
Zack
|
|
|
|
|
Your best bet with this is to google the terms which relate to this procedure, I would, but im struggling to name it - you may know better as you are dealing with it.
Once you find something that looks relevant, post links to the information you find, and im sure someone here can help you turn that into some code.
Although, you may be lucky, someone out there *might* just know this off the top of their head, the internet is a big place.
|
|
|
|
|
any one have id how can make search in side pdf file ?
the pdf file upload in date base as binary .
Palestine
|
|
|
|
|
I don't know whether these libraries[^] can help you, but take a look
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Am having a Treeview with many nodes each of which have their own subnodes...
I want to move and copy the selected node(if one node selected,hence its subnodes too) to another treeview...
How can i do it...
Can anyone help me in codes...
Thanx....
|
|
|
|
|
Mahi.V.Ragava,
Let's assume that you have two TreeView s (treeView1 and treeView2 ) and a button (button1 ) to move TreeNode s from treeView1 to treeView2 . Then, you can have the following event handler.
private void button1_Click(object sender, System.EventArgs e)
{
if( treeView1.SelectedNode != null && treeView2.SelectedNode != null )
{
TreeNode n = treeView1.SelectedNode;
treeView1.SelectedNode.Remove();
treeView2.SelectedNode.Nodes.Add( n );
}
} When you get the reference to the selected node in the first tree, its Nodes collection already contains all subnodes. Therefore, when you add that TreeNode to the second tree, all the subnodes already exist and get put in automagically.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thanx curtis for ur brief code...
But i want to transfer by dragging the source treenode and drop it in the target treeview,provided that the source node should also exist.....
cud u help me for this ,plzzz
|
|
|
|
|
This answer details an extremely minimal implementation of what you want. It assumes that you have two TreeView s on your form with names treeView1 and treeView2 .
treeView1.MouseDown += new MouseEventHandler( SourceTreeMD );
treeView1.MouseUp += new MouseEventHandler( SourceTreeMU );
treeView1.MouseLeave += new EventHandler( SourceTreeML );
treeView2.DragDrop += new DragEventHandler( TargetDrop );
treeView2.DragEnter += new DragEventHandler( TargetEnter ); As implementations of the above declared event handlers, you need the following in your form class.
private void SourceTreeMD( object sender, MouseEventArgs mea )
{
draggedNode = treeView1.GetNodeAt( mea.X, mea.Y );
}
private void SourceTreeMU( object sender, MouseEventArgs mea )
{
draggedNode = null;
}
private void SourceTreeML( object sender, EventArgs ea )
{
if( draggedNode != null )
{
treeView1.DoDragDrop( draggedNode, DragDropEffects.Move );
}
}
private void TargetDrop( object sender, DragEventArgs dea )
{
Point p = treeView2.PointToClient( new Point( dea.X, dea.Y ) );
TreeNode dropTargetNode = treeView2.GetNodeAt( p );
TreeNode sourceNode = dea.Data.GetData( typeof( TreeNode ) ) as TreeNode;
if( dropTargetNode != null && sourceNode != null )
{
sourceNode.Remove();
dropTargetNode.Nodes.Add( sourceNode );
}
else if( sourceNode != null )
{
sourceNode.Remove();
treeView2.Nodes.Add( sourceNode );
}
}
private void TargetEnter( object sender, DragEventArgs dea )
{
if( dea.Data.GetDataPresent( typeof( TreeNode ) ) )
{
dea.Effect = DragDropEffects.Move;
}
}
private TreeNode draggedNode;
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thanx Curtis....
But if i set breakpoint in the TargetEnter and TargetDrop,when i use the mouse to drag a node from source and place it in the target,its not working...
Also,the nodes in the source neednot be removed...
How can i do this...
Plz..Help...
|
|
|
|
|
When you set the breakpoint, it messes with the mouse events. Don't do it.
To not remove the nodes in the source tree, remove the line that reads something like sourceNode.Remove(). You'll have to clone the nodes, then, methinks.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
|
My pleasure. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|