如何创建域名并使用该域名获取数据 [英] how to create domain name and get data using this domain name

查看:92
本文介绍了如何创建域名并使用该域名获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想动态创建域名(例如user1.example.com),并想获取第一个单词,即user1从数据库中获取数据.请举一个例子进行答复.

Hi All,

i want to create domain name dynamically(like user1.example.com)and want to get first word i.e,user1 to fetch data from database.please reply with an example.

推荐答案

好.这似乎是非常简单的字符串操作.查看String.SubString和String.IndexOf.您可以在域名中获得第一个句点的位置,然后使用它来获取字符串的前x个字符以获取名称.
OK. This appears to be very simple string manipulation. Look at String.SubString and String.IndexOf. You get the position of the first period in the domain name then use that to grab the first x number of characters of the string to get the name.


mDaves的变体答案:Ese 将字符串分成不同的部分,并使用String.Substring(0,1)来获得结果数组中第一个元素的第一个字符.
A variation ofmDaves answer: Ese String.Split(".") to break the string up into separate parts and the use String.Substring(0,1) to get the first character of the first element in the resulting array.


这篇关于如何创建域名并使用该域名获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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