Оптимизация работы класса - C# (179476)
Формулировка задачи:
Нужно максимально, оптимизировать работу двух методов в классе. Возможно ли как-нибудь ускориться?
class Proxy
{
#region Fields
#endregion
#region Properties
public string Ip { get; private set; }
public int Port { get; private set; }
public string Content { get; private set; }
public ProxyType Type { get; private set; }
public int Timeout { get; set; }
public string Country { get; set; }
#endregion
#region Constructors
public Proxy(string Content,ProxyType Type)
{
this.Content = Content;
this.Type = Type;
SplitContent();
}
public Proxy(string Ip,int Port,ProxyType Type)
{
this.Ip = Ip;
this.Port = Port;
this.Type = Type;
BuildContent();
}
#endregion
#region Methods
private void SplitContent()
{
Ip = Content.Substring(0, Content.IndexOf(":"));
Port = Convert.ToInt32(Content.Substring(Content.IndexOf(":") + 1));
}
private void BuildContent()
{
Content = String.Format(@"{0}:{1}",Ip,Port);
}
#endregion
}Решение задачи: «Оптимизация работы класса»
textual
Листинг программы
private void SplitContent()
{
string content = "127.0.0.1:8080";
string ip = content.Split(':')[0];
int port = int.Parse(content.Split(':')[1]);
}