|
JF2015 wrote: public string number = new string[20];
That should be
public string[] number = new string[20];
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
Hi Vikram,
if I try this I get an error saying:
Compiler Error CS0573
Error Message
'field declaration' : cannot have instance field initializers in structs
So, obviously I can't initialize this array within the struct, but initializing the array out of the struct as:
Order or = new Order();
or.Number = new or.Number[20];
is also not working.
|
|
|
|
|
Create a default constructor that initialises the field.
JF2015 wrote: or.Number = new or.Number[20];
That's never going to work, what do you expect it to do ? or.Number = new string[20]; assuming it's an array of strings, is what you need.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Ok,
my fault, i originally thought that i had to initialize the array within the struct, but didn't know i had to do it like you wrote.
Thanks alot
|
|
|
|
|
Glad to help
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm sorry, I wasn't paying attention to the fact that you wanted it inside a type.
Cheers,
Vıkram.
Déjà moo - The feeling that you've seen this bull before.
Join the CP group at NationStates. Password: byalmightybob
|
|
|
|
|
Hello!
I have a string which has numbers(digits) at the beginning(don't know how many) and letters at the end(again, don't know how many).
What regex pattern should I use to get just the first part(the numeric one)?
ex:
34546AX -> 34546
12ELFY -> 12
Thanks.
|
|
|
|
|
[0-9]{1,}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thank you.
Learning Regular Expressions has been on my TODO list for some time, but somehow, something else always got in front of it in the waiting queue.
By the way, could you recommend a good resource for learning regex?
Thanks again.
|
|
|
|
|
blackjack2150 wrote: Thank you.
You're welcome.
blackjack2150 wrote: By the way, could you recommend a good resource for learning regex?
Oh, I'm not an expert about. I usually read MSDN (that usually is great), but IMHO Regex topic is not that good...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
for biginning of word use <[0-9]+
for biginning of line use ^[0-9]+
|
|
|
|
|
Hi,
I am using TCPClient for requesting web pages.
ex:
string Ahost = "http://www.Google.co.in";
Uri lastURI=new Uri(Ahost);
TcpClient client = new TcpClient();
string host = lastURI.Host;
string temp = lastURI.PathAndQuery;
client.Connect(host, lastURI.Port);
NetworkStream stream = client.GetStream();
string str = @"GET " + temp + " HTTP/1.1" + "\r\n" +
@"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*" + " \r\n" +
@"Accept-Language: en-us" + "\r\n" +
@"Accept-Encoding: gzip, deflate" + "\r\n" +
@"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" + "\r\n" +
@"Host: " +host+ "\r\n" +
@"Connection: Keep-Alive" + "\r\n\r\n";
byte[] send = Encoding.ASCII.GetBytes(str);
try
{
if (stream.CanWrite)
{
stream.Write(send, 0, send.Length);
}
}
catch (System.IO.IOException ioe)
{
Console.WriteLine(ioe.Message);
}
byte[] bytesToRead = new byte[client.ReceiveBufferSize];
MemoryStream ms = new MemoryStream();
StringBuilder sbuild = new StringBuilder();
do
{
try
{
int numBytesRead = stream.Read(bytesToRead, 0, client.ReceiveBufferSize);
Console.WriteLine(numBytesRead.ToString());
ms.Write(bytesToRead, 0, numBytesRead);
Console.WriteLine(ms.Length);
}
catch (Exception e)
{
Console.WriteLine("No Data Found");
}
}while(stream.DataAvailable);
ms.Seek(0, 0);
StreamReader sr = new StreamReader(ms,Encoding.ASCII);
string Result = sr.ReadToEnd();
sr.Close();
ms.Close();
stream.Close();
client.Close();
Console.WriteLine(Result);
}
}
In the above case How can i use the same TCPClient object for more than one
request provided the host is same.(in case of requests like
http://www.google.co.in/
http://www.google.co.in/intl/en_com/images/logo_plain.png
http://www.google.co.in/images/nav_logo3.png )
Please Help
Sakthi.
|
|
|
|
|
string[] str1 = new string[3] { "http://www.google.co.in/", "http://www.google.co.in/intl/en_com/images/logo_plain.png", "http://www.google.co.in/images/nav_logo3.png" };
string Ahost = "http://www.Google.co.in";
Uri lastURI=new Uri(Ahost);
TcpClient client = new TcpClient();
string host = lastURI.Host;
client.Connect(host, lastURI.Port);
NetworkStream stream = client.GetStream();
for (int i = 0; i < str1.Length; i++)
{
string temp = new Uri(str1[i]).PathAndQuery;
string str = @"GET " + temp + " HTTP/1.1" + "\r\n" +
@"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*" + " \r\n" +
@"Accept-Language: en-us" + "\r\n" +
@"Accept-Encoding: gzip, deflate" + "\r\n" +
@"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" + "\r\n" +
@"Host: " + host + "\r\n" +
@"Connection: Keep-Alive" + "\r\n\r\n";
byte[] send = Encoding.ASCII.GetBytes(str);
try
{
if (stream.CanWrite)
{
stream.Write(send, 0, send.Length);
}
}
catch (System.IO.IOException ioe)
{
Console.WriteLine(ioe.Message);
}
byte[] bytesToRead = new byte[client.ReceiveBufferSize];
MemoryStream ms = new MemoryStream();
StringBuilder sbuild = new StringBuilder();
do
{
try
{
int numBytesRead = stream.Read(bytesToRead, 0, client.ReceiveBufferSize);
Console.WriteLine(numBytesRead.ToString());
ms.Write(bytesToRead, 0, numBytesRead);
Console.WriteLine(ms.Length);
}
catch (Exception e1)
{
Console.WriteLine("No Data Found");
}
} while (stream.DataAvailable);
ms.Seek(0, 0);
StreamReader sr = new StreamReader(ms, Encoding.ASCII);
string Result = sr.ReadToEnd();
sr.Close();
ms.Close();
//stream.Close();
stream.Flush();
Console.WriteLine(Result);
}
client.Close();
|
|
|
|
|
Hi Subrata,
Actually in my case i may not know the URLs in advance.
If the host of requested url is same as the host of Previous Url
I should be able to use the same connection.
I tried the same without closing the underlying connection.
While reading for the next request,i am getting an exception as
Connection closed. Is it possible set the connection timeout.
Sakthi.
|
|
|
|
|
But please help
<code>string fullString = @"value1;value2;value3";
string []arString =
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
string[] arString=fullString.Split(';');
This will split your string.
Sakthi
|
|
|
|
|
I knew that was a terribly stupid question to ask
Thanks Sakthi
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
string[] arString = fullString.Split(';');
|
|
|
|
|
Thank you
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi
Please let me know why we are choosing C#.Net instead of VB.Net. What is the basic difference between these two. And Why C#.Net is more preferable than VB.Net. Thanks alot
Thanks and Regards
Venkat
|
|
|
|
|
|
venkatasivaramaprasad wrote: Please let me know why we are choosing C#.Net instead of VB.Net.
Well, not all of us are. Those who are, probably are because we came from C++. The only reason I know of to use C# is unsafe blocks. The reasons to avoid VB.NET include all sorts of nastiness, like hard to read code, 'magic' conversions that can really bite you when you don't expect them, and the VisualBasic namespace, which is full of rubbish imported from VB6.
But, if you know how to navigate the minefield that is VB.NET, the end code is basically going to run the same and do the same things.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
because vb is so ugly that when I look at some vb code I don't know whether to say "bue.." or "yuk!!"..
life is study!!!
|
|
|
|
|
Hi,
I am developing a chatting application with a Web Service as the central monitoring Server.
The Web Service methods will be used by the clients (Windows and Web) to Add User, Send and Recieve messages.
Can anyone help me in realizing this functionality as I have less knowledge on Web Service?
A sample code with this regard will also be helpful
Thanks in advance,
Murali
|
|
|
|
|
Ur Server code will have all the functionality of Add User, Send and Recieve messages. Then add a webservice to this server project. In the webservice add distinct WebMethods for each of ur task. Create a instance of the server inside this method and make an appropiate call.
ex. server.cs-
class server
{
AddUser(){}
}
in webservice.asmx
class service
{
[webmethod]
AddUserService()
{
server sr = new server();
sr.AddUser();
}
}
This example is just to help u to start. Once u start u can know how to invoke methods.
|
|
|
|