using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Protocol
{
public void InputData() {
string url;
string protocol;
Console.WriteLine("请输入一个HTTP或者FTP地址:");
url = Console.ReadLine();
protocol = GetProtocol(url);
Console.WriteLine("你输入的地址使用的协议类型是:");
Console.WriteLine(protocol);
Console.ReadLine();
}
private string GetProtocol(string url) {
int position;
string protocol;
position=url.IndexOf(":");
if (position > 0)
{
protocol = url.Substring(0, position);
}
else {
protocol = "没找到";
}
return protocol;
}
}
}
<
C# 第四章上机练习1
最新推荐文章于 2018-09-04 09:40:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)