|
A few thoughts:
if i=0 and m=011 how do you determine, when parsing, that a value of 0 is 'i' or the start of 'm'? The answer is that you need to have a defined way of making each value unique. A pointer for you would be to base your 0's and 1's from morse code, where this uniqueness is enforced - also morse (in case you dont know) is made up of dots and dashes - very fitting with your 1's and 0's
Ok, onto parsing the string - take a look at StringTokenizer's - there are at least two articles here on CP about the principle - and it is basically what you want - in (unwritten) code;
StringTokenizer st = new StringTokenizer("011010101");<br />
string convertedString = "";<br />
while(st.HasMoreTokens)<br />
{<br />
char nextChar = st.NextToken();<br />
convertedString += nextChar;<br />
}
|
|
|
|
|
This problem is potentially non-trivial.
There are two things your forgot to specify. The first is whether there can be more than one correct parsing for each string. For example, your string parsed to "mike", but (with the right additional codes) it could also have parsed to pratically any other alphanumeric output. This is key in determining when and how the algorithm should terminate. The second problem is one of scope. How long is the input string and how big is the table of values? The way the algorithm will work is to search through the space of ALL POSSIBLE parsings and output those that complete. Clearly, the bigger your input string and lookup table get, the more the chances of seeing a 'combinatorial explosion'.
If you answer these questions, I will help you write the algorithm. Please let me know if you are comfortable with embedded recursion, or your pefer iterative processes. The former is much more elegant, but with big inputs could create memory problems.
-- modified at 6:45 Wednesday 9th November, 2005
|
|
|
|
|
I prefer embedded recursion. There can be more than one correct parsing for each string, and for this example, the table is limited to the alphabet (lower-case and upper-case) and also '\n', ' ', and '\t'.
I love to program!
|
|
|
|
|
|
Hi Everyone,
If anyone could help me out i'd really appreciate it because this problem is really holding back the project. I'm getting the dreaded
Source File: c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config Line: 198 problem
which i'm pretty sure one or two of you might be familiar with seeing as there are threads on it all over the internet. The reason i'm posting this is because i've tried every solution on the threads i've seen and none work. Restarting the computer, adding a blank space to my web config file, turning off indexing service (it wasn't on in the first place), replacing the .DLL's with ones from their main build, clearing out the VS Cache and rebuilding. None of which worked, still the same error when i try to run my web project which leaves me at a virtual standstill as everything else i need to develop is dependent on this.
If anyone has a solution which is either a working variation of one of the above or a different way you found to get your web project back up and running i'd very much appreciate if you'd share it as i can't afford the time being wasted trying to find out whats wrong right now.
Cheers
|
|
|
|
|
Can anyone tell me please if its possible to bind a datagrid to an array of
objects (defined by me) so that when i update the contents of the array, the
data grid updates its display.
Any tips would be greatly appreciated.
Greg.
|
|
|
|
|
|
Hi
Please could someone help me to convert the following to Visual Basic.. or alternatively post a table driven version
It is a CRC16 algorithm using the polynomial (x16 + x15 + x2 + 1) used for very short strings.
I think (not sure) a test string of "123456789" should generate a hex checksum of: BD3B
Tks
Richard
static unsigned BitsSet (unsigned char ch)
{
unsigned n;
n = 0;
while (ch)
{
n += (ch & 1);
ch >>= 1;
}
return(n);
}
unsigned CRCof (const char *message, unsigned len)
{
unsigned i;
unsigned crc;
unsigned char k;
crc = 0;
for (i=0; i<len; i++)
{
k = (unsigned char)(message[i]) ^ crc;
crc = (crc / 256) ^ (k*128) ^(k*64);
if ((BitsSet(k) & 1) != 0)
crc ^= 0xC001;
}
return(crc);
}
|
|
|
|
|
Hi all,
I'm using ftp with the command "NLST *.*\r\n". After I send this command I get a reply:
"226 Transfer complete". I just want to get the file list, the weird thing is that
Sometimes the command works and sometimes doesnt.
The commands: USER, PASS, CWD and PASV work FINE before "NLST" command.
Any idea why?
thanx
-- modified at 6:29 Wednesday 9th November, 2005
|
|
|
|
|
I want to bind a ComboBox with a DataSet by supplying a datasource and
also want to specify ComboBox.valueMember and ComboBox.DisplayMember in a
windows form in C#. What i m trying is below the piece of code but i m
not getting the required result;
ComboBox1.DataSource = DataSet1;
ComboBox1.DisplayMember = "StudentName";
ComboBox1.ValueMember = "StudentID";
How to Bind ComboBox1 with DataSet1 ? Please correct the above code
snippt.
|
|
|
|
|
Try this snippet. I think you simply didn't bind to the Table, rather than the data set.
DataSet ds = new DataSet();
DataTable t = new DataTable("Students");
t.Columns.Add("StudentID", typeof(int));
t.Columns.Add("StudentName", typeof(string));
ds.Tables.Add(t);
for(int i = 0; i < 5; i++)
{
DataRow r = t.NewRow();
r["StudentID"] = i;
r["StudentName"] = "Test Student " + i.ToString();
t.Rows.Add(r);
}
comboBox1.DataSource = ds.Tables[0];
comboBox1.ValueMember = "StudentID";
comboBox1.DisplayMember = "StudentName"; Access the selected value:
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
MessageBox.Show(comboBox1.SelectedValue.ToString());
}
|
|
|
|
|
you need to add more qualification.
ie.
ComboBox1.DataSource = DataSet1.Table
or
ComboBox1.DataSource = DataSet1;
ComboBox1.DisplayMember = "Table.StudentName";
ComboBox1.ValueMember = "Table.StudentID";
Cheers
|
|
|
|
|
G'day folks,
I am stuck on a form design problem which I just cant seem to find any solution. I have an application (Parent Form) which requires another window (child form) to be open in a modeless mode (using Show()) and whose TopMost property is set to true. My problem becomes that if I switch applications in the taskbar, say from my application to Outlook (running in maximized mode), the child form still stays on top of Outlook. This is because the child form is set to TOPMOST being true.
One solution I had was to use the Deactivate and Activated event handlers for the parent form. In the Deactivate event handler I setup so that the child form would become invisible and in Activate Handler the child form would become visible. I didnt realise that once the parent form become active it will then make the child form visible thereby the child form become the active form thus firing the Deactivate handler for the parent form. Therefore getting stuck in an infinite loop of child form appearing and disappearing.
There has to be a solution since when the find window is open in notepad and another application is active the find window from notepad doesnt dominate.
Can anyone point out what mistake I am making, I realise this has to be a very elementary mistake.
I would really appreciate any feedback.
thanks
Vee
|
|
|
|
|
Don't use the TopMost property which is 'absolute', but the Owner property which describes a 'local order' in your application's forms set.
Tchimbaw
|
|
|
|
|
thanks for the tip. You have just saved me from having a sleepless night .
|
|
|
|
|
hi
how to add module in c#.net? There is no option in the menu project-> add module in c#.net which we have in vb.net.
sarayu
|
|
|
|
|
why do you need this, a class with static methods has equivalent functionality
|
|
|
|
|
I am trying to programatically remove cookies and temp internet files. I have found examples of how to change the Expire of cookies via Web Dev. But the Request.Cookies() doesn't work in Windows Dev.
My program is simple,
<br />
static void Main(string[] args)<br />
{<br />
LaunchWindows();<br />
}<br />
private static void LaunchWindows()<br />
{<br />
System.Diagnostics.Process.Start("IExplore.exe","http://lbprdapps:88/autosys/login"); <br />
}<br />
private static void ClearCache()<br />
{<br />
}<br />
Here is the VB equivalency in Web Dev. that I want to accomplish.
<br />
Dim i As Integer<br />
Dim cookieName As String<br />
Dim limit As Integer = Request.Cookies.Count - 1<br />
For i = 0 To limit<br />
aCookie = Request.Cookies(i)<br />
aCookie.Expires = DateTime.Now.AddDays(-1)<br />
Response.Cookies.Add(aCookie)<br />
Next<br />
Any help would be appreciated.
TIA,
Scott
|
|
|
|
|
Hi all,
i'm woking on a project which uses .Net remoting architecture.
Previously i wasn't gettin this error, but now sometimes i get his error, and i cant figure out why it comes..and how to fix it.
Please if any one knows about it, do tell what to do..
Error: Timedout expired. The timeout period elapsd prior to obtaining a connection from the pool. This may have occured because all the pooled connections weer in use and max pool size was reached..
Thanx
|
|
|
|
|
Hi all,
Can someone please tell me how can I build a C# COM Object from VC++ 6.0?
Best Regards,
E.A.
|
|
|
|
|
E6AD wrote: how can I build a C# COM Object from VC++ 6.0?
You can't. Do you mean to call one ? The same as you call any COM component, COM is language neutral.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks a lot Christian. You are right,I meant to call.
Thanks,
E.A.
|
|
|
|
|
How do I create a shorcut (in the esktop)for an existing exe file?
|
|
|
|
|
You need to pinvoke some shell stuff to do that, from memory.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi everyone,
Can someone please tell me how can I build a DLL in C#?
Best Regards,
E.A.
|
|
|
|