|
Hmm, you should consider using "Trim" or "TrimEnd" instead of "Substring" - after all, you want to - well - trim
It will save you the clumpsy "if" construction as well.
|
|
|
|
|
Thank you, the first one worked. so after i checked if there is a "," at the end of the string it just leaves it out. but i'll use the trim end next time. thanks.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
On another note, something faster, and optimized than substring or trimending
(think what shall happen calling substring on a very huge string?)
strNum[strNum.Length-1] = string.Empty;
There are few scenarios where this will be the best and others where this wont be a better idea.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
Two problems with your code:
strNum[index] is a char. string.Empty is a string. You can't assign a string to a char.
Strings can't be changed. Hence strNum[index] is a read-only indexer.
So I do not see how this should work. Using a StringBuilder might help if the strings are repeatedly modified, but for a single trim operation it would not make any sense.
|
|
|
|
|
I'm try to write my own picture viewer using the MDI format.
Have the basic setup done.
Need help on how to load a picture/image into the active ChildMDI form.
Do you load the picture/image into a picturebox or something else.
Thanks,
Steve C#freak
|
|
|
|
|
Easiest way is to load it into a pictureBox. You can do something like:
Image image = Image.FromFile( "c:\\blah.jpg" );
pictureBox.Image = image;
My pointless rants
http://meragussa.blogspot.com
|
|
|
|
|
Thanks for the help.
I'm trying to load the image into the activeChild.
Do not know how to go about this.
eg; select open image from the MdiParent, and have it open in the active MdiChild form.
Greatfull for all comments/Help given.
Thanks
Steve C#freak
|
|
|
|
|
In the main application which is the parent of all MDI Child form do something like
((MyMdiForm)this.ActiveMdiChild).SetImage( image );
ActiveMdiChild will get you the active mdi child. You need to make sure your MDI child supports a Method to accept an Image or file path to an image.
In MyMdiForm.SetImage( Image image );
Do something like:
pictureBox.Image = image;
|
|
|
|
|
Acctually I have one radio server.when I connect that server from Windows Media Player it is not connecting,but it is working fine for apple Itune and Quick time player,can anyone tell me why is it happening?Do i need to do some special settings in Media Player????
nishu
|
|
|
|
|
Are you trying to connect using C#, or have you posted this in a completely irrelevant message board?
---
b { font-weight: normal; }
|
|
|
|
|
My Server is in c# only!!!
nishu
|
|
|
|
|
hi all,
posted this (similar to) yesterday and didn't stir anyones reflection juices, so i worked on it some more and hopefully i am gettign closer.
I want to, given a control, and an event, find it's addEvent's delegate's parameters. More specifically teh second (usually) that extends (usually again) EventArgs .
this is my code so far. please see comments inside foreach loop
private void RegisterControlEvent()
{
Control control = this.NamingContainer.FindControl(ControlTrigger);
if (control == null) { return; }
string eventName = ControlCoverter.GetEventName(control);
if (eventName == string.Empty) { return; }
EventInfo ei = control.GetType().GetEvent(eventName);
ParameterInfo[] param = ei.GetAddMethod().GetParameters();
Type type = null;
foreach (ParameterInfo p in param)
{
type = p.Member.DeclaringType;
}
if (type != null)
{
MethodInfo mi = this.GetType().GetMethod("GenericControl_TriggerEvent");
MethodInfo constructed = mi.MakeGenericMethod(new Type[] { type });
Delegate del = Delegate.CreateDelegate(ei.EventHandlerType, constructed);
ei.AddEventHandler(control, del);
}
}
public void GenericControl_TriggerEvent<T>(object sender, T e)
{
.
.
.
}
am I approaching this completely the wrong way ?
kind regards,
g00fy
|
|
|
|
|
I know it's not a finished product, but they are calling it RC, so it should be close to finished.
Anyway, in the .NET 2 framework, a main window was separated into well known areas such as status bar area, toolbar area, document area, etc. I see nothing of that now. Have I totally missed something, or am I supposed to sit and tweak stuff like that "by hand"??
--
Torn from tomorrow's headlines
|
|
|
|
|
Hi Jorgen
I'm not too familiar with WPF just yet, but a quick search turned up this post[^] that talks about the different positioning techniques available in the WPF toolkit.
|
|
|
|
|
Thanks for the link! I'm sure there must be some "idioms" for creating "old school" GUIs. I tried using some of the layout stuff, but buttons and whatnot I put in it, just wouldn't render. I admit it's late, I'm tired, and have a fever. Maybe I'm just delerious?
--
Torn from tomorrow's headlines
|
|
|
|
|
Believe me, it's not easy. I've been 'playing' trying to create a user control that mimics an Outlook navigation pane and so far it's taken me 2 weeks to just get the layout 75% right.
Trying to do layout in code (C# or XAML) is long winded and error prone. Which leaves the VS Designer which seems far from finished.
|
|
|
|
|
I wrote recursive function where i need to pass array of integer and output a collection of arraylist in main
Below is how i did but how can i change my program
to out put recive a arraylist and print out in main
Please help
Thankyou
public class PermutationsLex
{
[STAThread]
static void Main(String [] args)
{
int [] a=new int[] {3,4,2};
ArrayList sa= Permute(a,0,a.Length-1);
Console.ReadLine();
}
static ArrayList Permute(int[] a, int start, int finish)
{
System.Collections.ArrayList permutationsList= new System.Collections.ArrayList();
if (start == finish)
{
// for (int i = 0; i <= finish; i++)
// {
// Console.Write(a[i] + " " );
// }
// Console.WriteLine("");
}
else
{
for ( int i = start; i <= finish; i++)
{
swap(a,start,i);
Permute(a, start+1, finish);
swap(a,start,i);
}
}
}
public static void swap(int[] a, int i, int j)
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
|
|
|
|
|
aynka2000 wrote: how can i change my program
to out put recive a arraylist and print out in main
I don't understand what you mean by "out put receive a arraylist". Could you clarify?
Also, when you post code snippets in this forum, surround the code with <pre> tags. It makes it easier for people to look at your code and answer your question.
|
|
|
|
|
Currently in my function (static void Permute(int[] a, int start, int finish)) all the values in the permutation are printed recursively in a loop
I want to change the program so that my function Permute returns an array list of int [] arrays to the Main function in the program
static void Main(String [] args)
{
int [] a=new int[] {3,4,2};
ArrayList sa= Permute(a,0,a.Length-1);=Pass the Array List
Console.ReadLine();
Please help
Thankyou
public class PermutationsLex
{
[STAThread]
static void Main(String [] args)
{
int [] a=new int[] {3,4,2};
ArrayList sa= Permute(a,0,a.Length-1);
Console.ReadLine();
}
static void Permute(int[] a, int start, int finish)
{
if (start == finish)
{
for (int i = 0; i <= finish; i++)
{
Console.Write(a[i] + " " );
}
Console.WriteLine("");
}
else
{
for ( int i = start; i <= finish; i++)
{
swap(a,start,i);
Permute(a, start+1, finish);
swap(a,start,i);
}
}
}
public static void swap(int[] a, int i, int j)
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
<pre>
|
|
|
|
|
Hello
I don't think I get what you are trying to do!!
1- If you want to make an ArraytList from your array simply
ArrayList temp = new ArrayList(a);
2- If you want to swap your values you can do the same in the ArrayList instead of the array, and you don't have to make an entire method for that!! simple make a foreach loop to loop through your ArrayList in the premute method.
3- If you ant to return the ArrayList simply
public ArrayList Premute(int[] a)
{
ArrayList MyArrayList = new ArrayList(a);
return MyArrayList;
}
Yet I don't understand you logic in swapping!! I hope that was close enough.
Regards
|
|
|
|
|
I tried Using binary tree in c#
I just tried the insert,delete and find method using recursion
But I'm not sure whether is correct and how to use it in main Can somebody please tell is it correct
Thanks for checking
below is my coding
using System;
class Node
{
public int skey;
public Node nleft;
public Node nRight;
public Node left
{
get {return nleft; }
set {nleft=value; }
}
public Node right
{
get {return nRight; }
set {nRight=value; }
}
public int vkey
{
get {return skey; }
set {skey=value; }
}
}
class Tree
{
private Node root;
public Tree()
{
root = null;
}
//find
Node search_binary_tree(Node node,int key)
{
if (node==null)
return null; // not found
if (key < node.vkey)
return search_binary_tree(node.left, key);
else if (key > node.vkey)
return search_binary_tree(node.right, key);
else
return node;
}
void InsertNode(Node node,Node newNode )
{
if (root == null)
{
root =newNode;
}
else if (newNode.vkey <= node.vkey)
InsertNode(node.left, newNode);
else
InsertNode(node.right, newNode);
}
void DeleteNode(Node node)
{
Node temp = node;
if (node.left == null)
{
node = node.right;
temp=null;
}
else if (node.right == null)
{
node = node.left;
temp=null;
}
else
{
// Node has two children - get max of left subtree
temp = node.left;
while (temp.right != null)
{
temp = temp.right;
}
node.vkey = temp.vkey;
DeleteNode(temp);
}
}
void traverse_binary_tree(Node treenode)
{
if (treenode!=null)
{
traverse_binary_tree(treenode.left);
Console.WriteLine(treenode.vkey);
traverse_binary_tree(treenode.right);
}
}
So how can i apply main method for this
Please Help
Ayn
|
|
|
|
|
Your implementation has several flaws.
1) You don't need two classes Tree and Node, you can merge them into one.
2) methods like AddNode(), RemoveNode() and Search() have to be public
3) the contructor of a Node/Tree should ideally have a value parameter, like Tree(int value)
4) you don't need a root node in your tree, left and right childs are enough
5) when adding/searching/removing check for < and >= and not just > and <
Once you fix that, you may use it like that:
Tree binTree = new Tree(5);
binTree.Add(10);
binTree.Add(3);
There are lots of bintree examples on the internet, you can almost copy them 1 to 1, even the Java ones
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
I need to write a program using C# to create a certificate --- but first, I want to create a known RSA key pairs (public and private key) with my precalcuated RSA Modulus/Exponent, and use the public key to create the certificate.
Thanks.
Edward
|
|
|
|
|
|
Hi,
i) I want to create a pair of RSA keys --- how could I control a specific generation of the key pair (the public and private key);
ii) Then I want to use the public key to form a digital certificate
iii) The digital certificate will distribute to my friend for encryption and I keep the private key for decryption
regards
|
|
|
|