谁知道怎么样...... [英] Anyone know how...

查看:58
本文介绍了谁知道怎么样......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

....将以下内容翻译成C#.NET样式?


var

i:整数;

开始

txtMyIP.Lines.Clear;

sHTML:= HTTP.Get(''http://www.network-tools.com/'');

如果sHTML =''''那么

退出;

sIpAddr:=''IP不可用。';

i := Pos(''host'',sHTML);

如果i = 0则

退出;

而sHTML [i]< ;> ''v''做

Inc(i);

if i> = Length(sHTML)then

退出;

Inc(i,7);

x:= i + 2;

而sHTML [x]<> ''"''做

Inc(x);

如果x> =长度(sHTML)则

退出;

sIpAddr:=复制(sHTML,i,x - i);


txtMyIP.Lines.Add(sIPAddr);


这是Delphi代码。 HTTP()部分是Indy IdHTTP组件。

我可以在VS2005中使用类似的东西吗?它通过解析来自network-tools.com的结果检索您的外部IP



在文本区域中向用户显示它。


任何正确方向的推动都会膨胀。没有直接翻译

除非有人想表明他们对这两种语言都很了解。

:)


非常感谢提前!

解决方案

查看system.web类
http://msdn2.microsoft.com/en-us/lib...ystem.web.aspx


它有HttpResponse和HttpRequest类


使用它们来创建请求并获得响应。

响应是你需要的文字。


如果你点击任一课程的链接,你会看到你需要的代码。


hth

raj


O-(''''Q)" < CA ************** @ gmail.com>在消息中写道

news:11 ********************** @ g49g2000cwa.googlegr oups.com ...

...将以下内容翻译成C#.NET样式?

我:整数;
开始
txtMyIP.Lines.Clear;
sHTML:= HTTP.Get(''http://www.network-tools.com/'');
如果sHTML =''''那么
退出;
sIpAddr:=''IP不可用。'';
我:= Pos(''主持'',sHTML);
如果i = 0则
退出;
而sHTML [i]<> ''v''做
Inc(i);
如果我> =长度(sHTML)然后
退出;
Inc(i,7);
x:= i + 2;
而sHTML [x]<> ''"''做
Inc(x);
如果x> =长度(sHTML)则
退出;
sIpAddr:=复制(sHTML,i,x - i);

txtMyIP.Lines.Add(sIPAddr);

这是Delphi代码。 HTTP()部分是Indy IdHTTP组件。是否有类似的东西我可以在VS2005中使用它来做到这一点?它通过解析来自network-tools.com的结果来检索您的外部IP,并在文本区域中将其显示给用户。

任何正确方向的推动都将是胀。除非有人想表明他们对这两种语言都很了解,否则不需要直接翻译。
:)

非常感谢提前!



> ...将以下内容翻译成C#.NET样式?


var
i:整数;
开始
txtMyIP.Lines.Clear;
sHTML:= HTTP.Get(''http://www.network-tools.com/'');
如果sHTML =''''那么
退出;
sIpAddr:=''IP不可用。'';
我:= Pos(''主持'',sHTML);
如果i = 0则
退出;
而sHTML [i]<> ''v''做
Inc(i);
如果我> =长度(sHTML)然后
退出;
Inc(i,7);
x:= i + 2;
而sHTML [x]<> ''"''做
Inc(x);
如果x> =长度(sHTML)则
退出;
sIpAddr:=复制(sHTML,i,x - i);
txtMyIP.Lines.Add(sIPAddr);

这是Delphi代码。 HTTP()部分是Indy IdHTTP组件。是否有类似的东西我可以在VS2005中使用它来做到这一点?它通过解析来自network-tools.com的结果来检索您的外部IP,并在文本区域中将其显示给用户。

任何正确方向的推动都将是胀。除非有人想表明他们对两种语言都很了解,否则不需要直接翻译。 :)

非常感谢提前!




只需从 http://www.indyproject.org/

在您的C#应用​​程序中引用它。


我觉得有点傻了。我从没想过甚至看起来和

看看Indy是否符合VS2005中的c#。 :o


原谅我提问我的问题,呵呵。


....to translate the following to C#.NET style?

var
i: Integer;
begin
txtMyIP.Lines.Clear;
sHTML := HTTP.Get(''http://www.network-tools.com/'');
if sHTML = '''' then
Exit;
sIpAddr := ''IP unavailable.'';
i := Pos(''host'', sHTML);
if i = 0 then
Exit;
while sHTML[i] <> ''v'' do
Inc(i);
if i >= Length(sHTML) then
Exit;
Inc(i, 7);
x := i + 2;
while sHTML[x] <> ''"'' do
Inc(x);
if x >= Length(sHTML) then
Exit;
sIpAddr := Copy(sHTML, i, x - i);

txtMyIP.Lines.Add(sIPAddr);

This is Delphi code. The HTTP() part is an Indy IdHTTP component. Is
there something similar I can use in VS2005 to do this? It retrieves
your external IP by parsing the results from network-tools.com and
displays it to the user in a text area.

Any nudges in the right direction would be swell. No direct translation
needed unless someone wants to show that they know both languages well.
:)

Many thanks in advance!

解决方案

Look at the system.web class
http://msdn2.microsoft.com/en-us/lib...ystem.web.aspx

it has HttpResponse and HttpRequest classes

use them to create the request and get the response.

reponse is the text you need.

If u click on link for either of the classes you will see the code you need.

hth
raj


"O-('''' Q)" <ca**************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...

...to translate the following to C#.NET style?

var
i: Integer;
begin
txtMyIP.Lines.Clear;
sHTML := HTTP.Get(''http://www.network-tools.com/'');
if sHTML = '''' then
Exit;
sIpAddr := ''IP unavailable.'';
i := Pos(''host'', sHTML);
if i = 0 then
Exit;
while sHTML[i] <> ''v'' do
Inc(i);
if i >= Length(sHTML) then
Exit;
Inc(i, 7);
x := i + 2;
while sHTML[x] <> ''"'' do
Inc(x);
if x >= Length(sHTML) then
Exit;
sIpAddr := Copy(sHTML, i, x - i);

txtMyIP.Lines.Add(sIPAddr);

This is Delphi code. The HTTP() part is an Indy IdHTTP component. Is
there something similar I can use in VS2005 to do this? It retrieves
your external IP by parsing the results from network-tools.com and
displays it to the user in a text area.

Any nudges in the right direction would be swell. No direct translation
needed unless someone wants to show that they know both languages well.
:)

Many thanks in advance!



> ...to translate the following to C#.NET style?


var
i: Integer;
begin
txtMyIP.Lines.Clear;
sHTML := HTTP.Get(''http://www.network-tools.com/'');
if sHTML = '''' then
Exit;
sIpAddr := ''IP unavailable.'';
i := Pos(''host'', sHTML);
if i = 0 then
Exit;
while sHTML[i] <> ''v'' do
Inc(i);
if i >= Length(sHTML) then
Exit;
Inc(i, 7);
x := i + 2;
while sHTML[x] <> ''"'' do
Inc(x);
if x >= Length(sHTML) then
Exit;
sIpAddr := Copy(sHTML, i, x - i);
txtMyIP.Lines.Add(sIPAddr);

This is Delphi code. The HTTP() part is an Indy IdHTTP component. Is
there something similar I can use in VS2005 to do this? It retrieves
your external IP by parsing the results from network-tools.com and
displays it to the user in a text area.

Any nudges in the right direction would be swell. No direct
translation needed unless someone wants to show that they know both
languages well. :)

Many thanks in advance!



Just download the Indy Project library from http://www.indyproject.org/ and
reference it in your C# application.


I feel a bit silly for missing that. I never thought to even look and
see if Indy was compliant with c# in VS2005. :o

Forgive me for asking my questions, hehe.


这篇关于谁知道怎么样......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆