如何在网址中存储Ipaddress [英] How to store Ipaddress in url

查看:91
本文介绍了如何在网址中存储Ipaddress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有ipaddress存储在字符串var = 192.168.1.2中,我必须将其存储在URL中作为tcp:// var:8084 / Class1我怎么能完成这个?我怎么能这样做?plz回答这个。

Say i have ipaddress stored in string var=192.168.1.2 and i have to store it in URL as "tcp://var:8084/Class1" how could i accomplish this?How could i do this?plz answer this.

推荐答案

更新:

请忽略此解决方案。问题本身并不清楚。我为弄乱这些事情而道歉。




首先,将你的字符串变量重命名为'var'之外的其他内容,因为在C#中它有不同的含义。还需要将值保持在一对引号内。

你可以做类似的事情 -

Update:
Please ignore this solution . The question itself was not clear. I apologise for messing up the things.


First of all, rename your string variable to something else than 'var' because in C# it has a different meaning. Also need to keep the value within a pair of quotes.
You may do something like-
string myIp="192.168.1.2";
string tempUri=@"tcp://"+myIp+@":8084/Class1";
Uri myUri=new Uri(tempUri);





希望,它有帮助:)

如果你的要求是别的,请告诉我。



Hope, it helps :)
If your requirement is something else then please let me know.


这篇关于如何在网址中存储Ipaddress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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