|
Hello. I got a code here in codeproject.com about radix sorting but it only sorts int based data. I want to use it to sort a string based data. My first try is I got first the ASCII codes of each characters in the strings then passed it in the radix sort code but what it gives me is totally different.
This is the link of the code that I got:
click here
Here is the output after getting the ASCII codes and pass it to the radix sort:
SHOW DATABASE: SORTING BY LAST NAME
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
97
97
97
110
110
111
111
111
114
115
115
115
117
122
122
What should I do for it to be able to sort string?
modified on Friday, September 4, 2009 6:02 AM
|
|
|
|
|
It would be more sensible to write a sort routine that accepts strings and sorts them by character order. Alternatively you could use one of the built in List/Array etc types that support sorting via one of their member functions.
|
|
|
|
|
Hi,
I don't know why you insist on using radix sort, as it will be slower than a regular sort when sorting strings.
Here is how it could work:
- determine the length L of the longest string;
- treat all strings as having length L by virtually appending NULL characters;
- the Nth "digit" of a string has a value that equals the (int) value of its Nth character (where you use zero if N exceeds the string length).
So sort all strings according to their (L-1)th character
then sort according to their (L-2)th character
etc
and finally sort according to their first character
As I said, it will be slow, as you have to get the characters, one by one, and compare those, whereas a normal sort would be based on a comparer method (such as string.Compare) that takes the whole string into account right away.
|
|
|
|
|
hello guys,
I am in a situation where I have an application that needs to be called from another application and then pass parameters and set properties to this application.
I cannot do this by Reflection as its not a DLL, and I cannot do it by calling Process.Start(..,arguments); and pass the arguments because the application dosen't have a public static void Main method.
Do you know any way in which i can achieve this guys?
|
|
|
|
|
??? What kind of application is that ???
Not a DLL but an EXE without start point ???
|
|
|
|
|
Yes sorry you have a point it has a public static void Main sorry my mistake . This is a normal windows forms application C#. now the thing is i can pass strings to the main method but i need to pass a reference to an instance of something. is that possible?
|
|
|
|
|
|
You can't pas a reference between processes. The reference will not valid in the process you're passing it to.
|
|
|
|
|
|
I am using VS 2005 and i have to read some images in the form of byte arrays and get those arrays in another form where i have to use these values and save them to database in Sql server. But the problem is that i am not able to read byte arrays from one form to another form. Please help. Any help would be appreciated.
Thanks
|
|
|
|
|
Hi,
what do you mean by "not able to read byte arrays from one form to another form"? Couldn't you just pass the byte-array within the constructor, a method, session-object etc.?
Regards
Sebastian
|
|
|
|
|
There are two different approaches fo passing data between objects depending on the relationship.
If the sending form instanciates the receiving form, then the receiving form should have a public property or method that is used to receive the data.
If the sending form was instanciated by the receiveng form then it should raise an event along with a custom event args instance (a class derived from System.EventArgs that holds the data to be passed).
If the forms are not so closely related, then a combination of these methods is often the best solution so the property/method or event is propogated up/down the class hierachy. If this gets too cumbersome, a separate 'manager' type class that is responsible for sending and receiving data between the objects it manages can also be a good solution.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Good answer
|
|
|
|
|
I want to retrive data from SQL database using C#.
and i want to put that data in DropDownList.
How can i do this?????
Please Help me.
Thanks In advance.......!!
|
|
|
|
|
and I want to put that data in DropDownlist without using data source
|
|
|
|
|
|
|
I think this can help u
u can use SqlDataAdapter and DataSet classes
SqlDataAdapter dd = new SqlDataAdapter();
DataSet de = new DataSet();
dd = new SqlDataAdapter("SELECT EmpName,isWaiter,isCashier FROM Employees", con);
de.Clear();
try
{
con.Open();
dd.Fill(de);
int k;
for (k = 0; k < de.Tables[0].Rows.Count; k++)
{
comboBox2.Items.Add(de.Tables[0].Rows[k].ItemArray[0].ToString());
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
|
|
|
|
|
using System.Data;
using System.Data.SqlClient;
Class test
{
public void pageload()
{
SqlConnection conn = new SqlConnection(@"User id:sa; Password:password; Initial catalog: databaseName; data source:localhost");
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT bob FROM table";
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
dropdownlist.Items.Add(reader["bob"].ToString());
}
reader.Close();
conn.Close();
}
}
|
|
|
|
|
dear friends,
i am using WMI code to get print job details. i am not able to get number of copies which the user enterd for printing.
is there any way to get number of copies user entered. could any one help me. using c# or c++
thanks in advance
Nishar A.
|
|
|
|
|
Not reliably. The number of copies is no part of the job. An applicaiton has two choices when printing multiple copies. Either it can tell the driver to render the copies, in which case, the driver has a choice, whether to render the copies itself, or have the printer do it, or the application can render each copy itself, where the driver will never know there is multiple copies of the same page being generated.
|
|
|
|
|
Hi
i am basically new to C# ? and all this might be simple for you ppl ...
i wanna know how i can access or call a function of a form (say A ) from a Form (say B) .
I wanna create an application that has multiple forms in it .
Ur help will be highly appreciated
|
|
|
|
|
delegate is the way to go. FormB should expose a delegate on which FormA can subscribe to get notifications. Alternate way is to make the method public and pass first form's object to second form through constructor.
|
|
|
|
|
Hey budy ........... I used static Public variables then I used the NameofTheForm.Var_Name if I want to acces only variables . Does this work for functions
Thank you
|
|
|
|
|
That really is a bad idea for a number of reasons:
1) Consider the case when you have two forms open - which one can "load" the static variable? How would the accessor know which had loaded it?
2) Exposing variables directly as public fixes the design of your class - because something may use the public variable, you cannot change how your class works without reflecting that in the public variable. If you expose this as a property, you can.
3) Accessing a different forms data is a bad idea from the start, as it fixes the design of one form to teh design of another. This means it is much harder to reuse classes, and thus does nothing to improve reliablity.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|