|
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
|
|
|
|
|
Hello
My last post was a nudge for you to ask a specific question -no offence please-. If you want to learn about a topic in general, may I suggest reading an article about it!! Take a look at This article[^], it has a source file included and I hope it would be of help.
If you are stuck in something specific while making your key pairs, we will be here.
Regards
|
|
|
|
|
Hi every one,
I am very new in IPC(InterProcess communication)and I'd like to know how to use it in my project.I read MSDN doc but my problem isn't solved.
If one has any source code that implements IPC between two applications please inform me.
yours sincerely.
Orchid
|
|
|
|
|
Hello
Take a look here[^].
Regards
|
|
|
|
|
i make winApp that will use DataBAse Connection For Long Time
during my application running i see this error
>>>>>>>>>>>>>>>>>>>>
Context 0x1a1a00' is disconnected.
Releasing the interfaces from the current context (context 0x1a1890).
This may cause corruption or data loss.
To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.
>>>>>>>>>>>>>>>>>>>>
i try to set ConnectionTimeout Property to 9000000
i see this error message
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Error 3 Property or indexer 'System.Data.Common.DbConnection.ConnectionTimeout' cannot be assigned to
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
that is the solutions ???
Palestine
|
|
|
|
|
sorry What is the solution ???
Palestine
|
|
|
|
|
Hello
ConnectionTimeOut is the time to wait while trying to establish a connection before terminating the attempt and generating an error. So, once you make the connection it's of no value. On the other hand, try to debug through your application and tell us where this error appears exactly?
Regards
|
|
|
|
|
just this error
Context 0x1a1a00' is disconnected.
Releasing the interfaces from the current context (context 0x1a1890).
This may cause corruption or data loss.
To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.
Palestine
|
|
|
|
|
Hello
My question wasn't if you have other errors or not!! My question was where exactly you get this error??
1- When you start your applications?
2- When you try to read/get data?
3- When you try to update data?
4- After staying idle -with no operations- for a while? How long?
5- When you close your application?
Two more questions:
1- Do you make your connection using the designer or in the code?
2- Is your application multithreaded? ie. Do you access the connection on multiple threads?
Regards
|
|
|
|
|
Hi...
In my application I have some listviews. I wanted to improve their appeareance adding an image to the headers. This is easy using smallimagelist of the listview class. The problem is that I want to show the sort arrow. For this I do it in this way:
IntPtr hHeader = Win32.SendMessage(this.Handle,Win32.LVM_GETHEADER,IntPtr.Zero,IntPtr.Zero);<br />
.<br />
.<br />
(more code)<br />
.<br />
.<br />
.<br />
Win32.SendMessage2(hHeader,Win32.HDM_SETITEM,new IntPtr(columnIndex),ref hd);
But when I click a header, the images dissapears.
Does anybody know a solution for this issue?
thanks
|
|
|
|
|
Hello
I assume you are using dllImport to send that message to your header cell. Why?? You can use myList.Columns[X].ImageIndex to show the arrow in your imagelist and change the arrow image in the ColumnClick event. Anyway, if you still want to use messages, try to resend the message in the click event handler.
PS.
What is Win32.SendMessage ??
Where do you put the above code?
Did you handle the ColumnClick event?? If so what do you do in it concerning the painting?
Regards
|
|
|
|
|
Of course, I´m using dllimport and I handled the ColumClick event. Win32 is only a class that hosts dllimports and other stuff. I know I can use ImageIndex to show the arrow. But... what I want is...to show an image and the arrow, at the same time.
What I want is something like this: http://www.codeproject.com/cs/miscctrl/XPTable.asp. But with listview 2.0.
kind regards and thanks for your answer
|
|
|
|
|
Hello
Well, one easier solution is:
1- Get the image from your ImageList;
2- Use a Graphics object to draw the arrow with the proper direction at the proper place of the image.
3- Show the image in your header!!
This way you won't need to use unmanaged calls!!
Regards
|
|
|
|
|
Using the native sending of messages is uncalled for here.
It is vanishing because the same init is not being persisted.
You need to couple creation message with every other message, if you insist in sending antive messages.
Though i can see two more ways of achieving the same result, though from unmanaged apps.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
Hi guys;
I was wondering if there is a 2D graphics via Direct3D engine or library that I could use.
I saw a site on this but the dll only works for the VB6 not C#.
www.dxgame.com[^]
I need something like the above but for use in C#.
Thanks
Hadi
|
|
|
|
|
Hello
Did you try to reference to it? Dlls in any language can still be used in C# if they support COM. Otherwise try using DllImport.
Regards
|
|
|
|
|
Yes its a piece of cake.
You have tons of game engines in the market that you can use for the same, through Interop. Also you can use the DirectX wrapping assemblies for achieveing the same results. I have created many DX based apps in the past using C# and though the performance is not as expected in lieu of the native version, still its respectable
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
Have you looked at Microsoft's recently released XNA[^] Game Studio?
|
|
|
|
|
I want to show one of the frames(First frame for example) of a video as a still image in windows media player control.( I have set the URL of the control to the video file address. Playing the video and pausing didn't work )
I would be so happy if anybody have any idea.
Yasamin
|
|
|
|
|
Hello
Since no one replied for more than 5 hours I'd try -as much as i can- guide you to what I think..
Media player be default -just as any other media player BTW- displays the video by hardware acceleration. This means that it doesn't just display a sequence of still images, when you pause it it will keep displaying the last one!! Anyway, if you want to display a still frame of a video you'd beter use managed DirectX library. Revise the video section in C# multimedia articles for more informations.
Regards
|
|
|
|