|
Hi, I have a MatchCollection1 which holds 1,2 and 3
MatchCollection2 holds A, B and C
now I want to print in below order,
1
A
2
B
3
C
how can i do that.
thank you
i think i need to do something like
<pre>
StreamWriter sw = new StreamWriter(@"file.txt");
foreach (Match match in MatchCollection1 )
{
sw.writeline(match);
//TODO get first item of collection in matchcollection2 and delete the first item.
</pre>
I also cant find Item property as stated in this link http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchcollection.item.aspx[^]
i dont know the todo part please help?
|
|
|
|
|
It is a bit confusing, what the MSDN page is saying (see its example) is that MatchCollection has an indexer (not really a property), i.e. you can use it as if it were an array; and that solves your problem entirely:
for (int i=0; i<MatchCollection1.Count; i++) {
Console.WriteLine(matchCollection1[i].Value);
Console.WriteLine(matchCollection2[i].Value);
}
which will fail if MatchCollection1 holds more entries than MatchCollection2.
FYI: They use similar words here[^].
Conclusion: it pays to look at the examples!
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
I have CookieContainer, which contained some cookies. How to get cookies from CookieContainer?
|
|
|
|
|
hello_amigo wrote: How to get cookies?
With GetCookies perhaps?
I don't know, I don't really want cookies.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Try using a search engine to find the answer before asking the question, honest it is quicker. Here is the MSDN [^]result thrown up by google
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ok, just simple exsample:
CookieContainer cc = new CookieContainer();
HttpWebRequest r1 = (HttpWebRequest)WebRequest.Create("URI1");
r1.AllowAutoRedirect = false;
r1.CookieContainer = cc;
HttpWebResponse h1 = (HttpWebResponse)r1.GetResponse();
foreach (Cookie c in h1.Cookies)
cc.Add(c);
HttpWebRequest r2 = (HttpWebRequest)WebRequest.Create("URI2");
r2.AllowAutoRedirect = false;
r2.CookieContainer = cc;
HttpWebResponse h2 = (HttpWebResponse)r2.GetResponse();
foreach (Cookie c in h2.Cookies)
cc.Add(c);
After this we have some cookies, which we got in the fist and secont responses. And cc contained this cookies.
Unfortunally, information on MSDN Link don`t explain how to get cookies from CookieContainer, just how to get cookies from concrete response.
|
|
|
|
|
|
|
foreach (Cookie cook in mycookie.GetCookies(new Uri("http://localhost")))
{
Console.WriteLine("----------------------------------------");
Console.WriteLine("Cookie:");
Console.WriteLine("{0} = {1}", cook.Name, cook.Value);
Console.WriteLine("Domain: {0}", cook.Domain);
Console.WriteLine("Path: {0}", cook.Path);
Console.WriteLine("Port: {0}", cook.Port);
Console.WriteLine("Secure: {0}", cook.Secure);
Console.WriteLine("When issued: {0}", cook.TimeStamp);
Console.WriteLine("Expires: {0} (expired? {1})",
cook.Expires, cook.Expired);
Console.WriteLine("Don't save: {0}", cook.Discard);
Console.WriteLine("Comment: {0}", cook.Comment);
Console.WriteLine("Uri for comments: {0}", cook.CommentUri);
Console.WriteLine("Version: RFC {0}", cook.Version == 1 ? "2109" : "2965");
// Show the string representation of the cookie.
Console.WriteLine("String: {0}", cook.ToString());
}
where mycookie is a cookie container that was got from the responce
|
|
|
|
|
I'm using TaskScheduler 2.0 by Dennis Austin and I have one question. One of the properties of creating the scheduled task is the user id and password. How can fill that in/get if the scheduled task is being created during an application install on a computer of someone I don't know.
|
|
|
|
|
If you mean TaskScheduler 2.0 by Dennis Austin[^] then post your question at the bottom of the article. Then he recieves an email to say you have a problem, and may respond. Otherwise, you are just hoping he comes to this forum and sees this...
(If you don't, then I can't help you).
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Hi All,
I have a fairly large solution, about 60 projects, which is right now configured to build for "Any CPU". Since we're moving to x64 servers, we decided to compile specifically for x64. I know that VS.NET (2008 in this case) does not do anything special if the build configuration is changed to x64 in case of C# projects. I merely adds a PE header in the IL which says it must be JITted as a 64 bit app. I changed the build configuration anyway and tried building it. But it complained that the various .NET assemblies used was x86, but since they were "Warning as Errors", I ignored them.
I know C++ has various compiler and linker directives that needs to be set if it has to be compiled as x64. Are there any such special things needed for C# projects, or do I just change the build configuration and hope that when the app runs, it'll run as 64 bit.
The project uses the .NET 3.5 framework and is actually a web service. I remember reading that some compiler optimizations will be made if it's targeted to x64, but cannot recall the source. So here are my questions
1. Apart from what I've done (Change build configuration) is there anything else that needs to be set?
2. The project still references the x86 versions of .NET assemblies, and it'd be too much of a pain if I were asked to change everything to refer the x64 assemblies. But assuming that the .NET assemblies are linked dynamically at runtime, would this matter?
3. There's no separate x64 version of .NET 3.5 (atleast I couldn't find one), only .NET 2.0. If this is the case, and the project uses .NET 3.5, would it really run as a 64 bit app, or just revert back to 32-bit mode at runtime? I've done and deployed "pure" 64 bit apps using .NET 2.0, but this is the first for .NET 3.5.
4. Will there be any compiler optimizations be done if it's targeted at x64 systems rather than "Any CPU"?
I've done quite a bit of reading, but couldn't nail down any authoritative source which explains porting to x64 using VS and for C# apps completely. It's either for C++ apps or just general reads on migrating to x64. Pardon my search skills if there's any real good source on the web and I overlooked it. If I get answer s for these queries, that's be great and accelerate my work, if not, it's back to numerous trial and error studies for me.
Thank You.
Apologies for the long question and the boring narration, but it's 1 AM here and my body's threatening to go into hibernation...
|
|
|
|
|
Oh well I don't know everything, but I can answer some of your questions:
1) Nothing, assuming that all your pointer magic is 64bit clean
2) I don't know, I never tried to do it wrong. It definitely does not work when you reference 32bit dlls for which there is no 64bit version, but for the rest I don't know.
3) .NET 2.0 contains a new CLR, .NET 3/3.5 are just extra class libraries, that could be why (not sure) - .NET 3.5 apps can certainly run in 64bit mode (they do on my computer)
4) Not that I know off, but the C# compiler barely does any optimizations anyway, some constant folding (and it can be fooled into not-folding really easily, such as 4+x+2 instead of x+4+2).. the JIT compiler has most of the optimizations (and the 64bit JIT has some more optimizations than the 32bit one)
edit: and I would like to add that when you're running a program on an x64 machine there is no significant difference between an Any-CPU build and an x64-only build - both will run in 64bit mode and both will fail when any of the dependencies doesn't have an x64/Any-CPU version. Neither Any-CPU nor x64 compiled apps will "revert to 32bit" on a 64bit machine, not under any circumstances, this is often a bad thing since many programs don't work in 64bit mode but are Any-CPU anyway (fortunately it's possible to edit them to be x86-only)
modified on Thursday, January 28, 2010 6:46 PM
|
|
|
|
|
Hello Everybody .... I have been working on C# Windows Application almost for 2 years and .. But now I wanted to start working on Devices like mobiles ... Is that possible to write some code and to run on mobiles?? .... If yes I will move on working on it ...just give me ur suggestions
Thank you alll
|
|
|
|
|
if your device supports the .NET Framework (or the .NET Compact Framework), then you can create apps for it using C#.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Is there any mechanism to know whether the .Net Framework work resides in or no? ... just for e.g .. I wanted to transfer Phonebook from ma PC to ma Nokia mobile ... using either bluetooth or USB cable ....
Thank you for your response
|
|
|
|
|
yes. it starts by reading the documentation to discover whether .NET *can* run or not on your mobile.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
You're a cruel man, Luc!
Luc Pattyn wrote: reading
Nasty.
Luc Pattyn wrote: documentation
Ouch!
Luc Pattyn wrote: discover
There is no excuse for that kind of language in here! Please go and wash your mouth out with <SOAP>
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
OriginalGriff wrote: wash your mouth out with soap
Sorry, can't do that, the soap documentation warns me against it. I'll have a instead. If that doesn't help, I'll try another one.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Thursday, January 28, 2010 2:46 PM
|
|
|
|
|
Nokia (AFAIK) have never used a Windows OS so no .NET Framework has ever been available on aby device of theirs. They mainly use their own OS or Symbian, on a few high end devices they have used Linux.
You're best bet might be to look at HTC (mainly Windows Mobile but some are Android) or a few recent Samsungs.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
So u r saying that i must have to learn their OS in order to operate on Nokia?
|
|
|
|
|
|
Hey ma frnds ... I was working on ListViewItem and I want to put check boxes on 2 columns ... Can u tell me how to do that?
Thank you.
|
|
|
|
|
|
hi, i need your help
when i insert data in my table show error
Error is
ERROR [42S02] [Microsoft][SQL Native Client][SQL Server]Invalid object name 'test'
and i use this coding
string MyString = "Select * from test";
OdbcConnection cn = new OdbcConnection("Driver={SQL Native Client};Server=localhost;UID=sa;PWD=java;");
OdbcCommand cmd = new OdbcCommand(MyString, cn);
cn.Open();
MessageBox.Show("Connected");
cmd.CommandText = "insert into test values ('" + textBox1.Text + "','" + textBox2.Text + "')";
MessageBox.Show(cmd.CommandText);
cmd.ExecuteNonQuery();
cn.Close();
Thanks In Advance
jawad khatri
|
|
|
|