|
|
Sir I am not clear about one thing please describe this. When I connect to internet I get ip www.whatismyip.com shows it. But my LAN ip is some thing else like 192.168.1.5. So when posting on some website this 192.168.1.5 has some effect. Example if I make a posting keeping my ip (LAN) as 192.168.1.5 and then make another using ip 192.168.1.34 and so on. Does my postings will be considered as from different systems or from the same system. As in LAN we use a single ip but we have different LAN ips different users are using different computers having the same proxy.
My question is this changing my computer (LAN) ip makes some effect on my identification on internet or not.
Thank You
|
|
|
|
|
Changing LAN IP does not change your external IP, sorry.
|
|
|
|
|
Waheed Ur Rehman wrote: My question is this changing my computer (LAN) ip makes some effect on my identification on internet or not.
No. If your ISP has provided you a static IP, your IP will always remain same. Dynamic IP is granted when you connect each time and this may change each time.
BTW, what this has to do with C#?
|
|
|
|
|
Dear Sir,
Is it possible to change the dynamic ip using C# without connecting disconnecting.
Thank You
|
|
|
|
|
|
it is possible. Simply create a WebProxy object and set webrequest.Proxy=proxy; Then your real ip will change for the request.
Thank You
|
|
|
|
|
|
There's no option that I know of, unless you have a database server that uses RegEx and is faster.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
The performance of a regular expression depends on how you write it, i.e. how many comparisons and backtracks it has to do to get the result.
For example, the pattern "A.+Z" looks for an A, then .+ matches the rest of the string. That means it has to backtrack by reducing what .+ matches a character at a time until it can find a match for Z also. The pattern "A.+?Z" looks for an A, then it starts by matching the non-greedy expression .+? against a single character, increasing the match until it finds the Z.
If you are not careful with greedy quantifiers and what you match, you end up searching most of the string many times over.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you very much for that insight into RegEx.
Here is a sample of one of the searches my application uses
(.*TOOLDEVSQL01[^\\].* )
I am not sure how I would speed this expression up, since I want a thorough search of config files, registry, binaries, etc.
I am going to research this. Please let me know if you have any ideas off the top of your head.
Thanks again!
Ryan
|
|
|
|
|
Try to change the first ".*" to ".*?" to make it non-greedy. That will scan the line forwards intead of backwards. If there is only a single space after the string that you match, you can change the second ".*" into ".*?" or "[^ ]*".
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
wow, this was great advice and insight. 90% of the performance issue was in my expression. While it still runs slower then other RegEx applications (ie. Windows Grep), it has vastly improved.
#1 I chunk search any binary bigger then 16kb
#2 instead of (.*TOOLDEVSQL01[^\\].* ) I use (?:TOOLDEVSQL01)(?: (?!\\))
The former expression also messed up my Regex.Replace, as it would replace the entire input string... I was using a much more simple expression when I first developed the application, your insight here has greatly helped. On one of my unit tests that used to take ~30 min, it takes about 30 sec, so its 10X faster!!
Much appreciated,
Ryan
|
|
|
|
|
Hi Guys
I'm having a problem with c#.
I have a Hotkey that is saved in the regist.
Well it saves ok etc.... But the problem is when i'm making the load... I make the load to a string and i can't pass that to a Hotkey....
I tryed like this:
Keys kk = Convert.ChangeType("Escape", Keys);
the error that says is:
'System.Windows.Forms.Keys' is a 'type' but is used like a 'variable'
|
|
|
|
|
zetrixfire wrote: But the problem is when i'm making the load
I'm not sure that's what you meant to say....
But, the error message means what it says. Keys is a type, and you're using it as a variable. Perhaps typeof(Keys) is what you need ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Use the Enum.Parse method to parse the string into a Keys value.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi all ,
I would like to know , when -in practice-
do we need object serialization over writing object fields directly to Database?
|
|
|
|
|
When you want to simplify your DB code so you can just serialise the entire object in one step. You're basically getting the system to write that code for you, to store the individual values, read them back and restore the state of an object. Also, serialisation can be used in places where the framework doesn't let you write your own code.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
I am trying to take the some information from a txt file and use them as values for variables. I am in the development stage and just trying to get a hang of what exactly is required to do this and then build up.
CODE:
using System;
using System.IO;
public class TextFromFile
{
private const string FILE_NAME = "e:\\test.txt";
public static void Main(String[] args)
{
if (!File.Exists(FILE_NAME))
{
Console.WriteLine("{0} does not exist.", FILE_NAME);
Console.Read();
return;
}
using (StreamReader sr = File.OpenText(FILE_NAME))
{
String fromtxt;
int IntValue;
while ((fromtxt = sr.ReadLine()) != null)
{
Console.WriteLine(fromtxt);
IntValue = Convert.ToInt32(fromtxt);
Console.WriteLine(IntValue);
}
Console.WriteLine("The end of the stream has been reached.");
Console.Read();
sr.Close();
}
}
}
In my case I have the text file simply have the number 5 written so the expected output is:
5
5
The end of the stream has been reached.
When I put:
while ((fromtxt = sr.ReadLine()) != null)
{
Console.WriteLine(fromtxt);
}
IntValue = Convert.ToInt32(fromtxt);
Console.WriteLine(IntValue);
I get the output:
5
0
When Keep put
while ((fromtxt = sr.ReadLine()) != null)
{
Console.WriteLine(fromtxt);
IntValue = Convert.ToInt32(fromtxt);
Console.WriteLine(IntValue);
}
Console.WriteLine(IntValue);
I get the error message:
Error 1 Use of unassigned local variable 'IntValue
|
|
|
|
|
The code inside the while loop you suggest might never be executed and the variable IntValue will not be assigned.
if you do someshing like:
IntValue = Int32.MinValue;
while ((fromtxt = sr.ReadLine()) != null)
{
Console.WriteLine(fromtxt);
IntValue = Convert.ToInt32(fromtxt);
Console.WriteLine(IntValue);
}
Console.WriteLine(IntValue);
The code will compile but that is bad logic.
you can also do something like:
IntValue = Int32.MinValue;
bool hasData = false;
while ((fromtxt = sr.ReadLine()) != null)
{
Console.WriteLine(fromtxt);
IntValue = Convert.ToInt32(fromtxt);
Console.WriteLine(IntValue);
hasData = true;
}
if(hasData)
{
Console.WriteLine(IntValue);
}
About the parsing. you should use :
bool parseOK = Int32.TryParse(fromtxt, out IntValue );
if(parseOK )
{
Console.WriteLine(IntValue);
hasData = true;
}
else
{
Console.WriteLine("Error the data is not an integer");
}
Natza Mitzi
|
|
|
|
|
In my program I have a DataGridView control on each TabPage in a TabPageControl, all DataGridViews have the same number and kind of columns. Now when the user clicks Print I want to amalgamate all the rows into one large DataGridView and print it. The first part is obvious but how would I print only the DataGridView?
|
|
|
|
|
You wouldn't, b/c the control itself never shows all the records. You'd iterate over the record set and write seperate printing code to print it all.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
If you start printing the second datagrid from the point on the page that the first one ends at, and so on, you should get effectively one printed grid.
|
|
|
|