我需要将char转换为int和back.
这是我用来将char转换为int的方法:
(char)65 // Returns 'a'
Run Code Online (Sandbox Code Playgroud)
以下是我正在尝试将其转换回来的内容:
(int)'a' // Returns 97
Run Code Online (Sandbox Code Playgroud)
任何想法我能做什么?
我无法让我的客户端在我的lindgren网络测试中连接到我的服务器.我尝试了多种连接方式,但是当我尝试连接时它总是停止.对不起,如果这是一个广泛的问题,但我做错了什么?这是我的代码:
class Program
{
static NetPeerConfiguration serverconfig;
static NetPeerConfiguration clientconfig;
static NetServer server;
static NetClient client;
static void Main()
{
Console.Title = "LidgrenNetworkTest";
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("LidgrenNetworkTest console initialized.");
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("Color codes: ");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("System ");
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("Input ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Sent ");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Received");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\n");
Console.WriteLine("Configuring server...");
serverconfig = new NetPeerConfiguration("LidgrenNetworkTest");
serverconfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
serverconfig.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
serverconfig.LocalAddress = NetUtility.Resolve("localhost");
serverconfig.Port = 8080;
Console.WriteLine("Server configured.");
Console.WriteLine("Configuring client...");
clientconfig = new NetPeerConfiguration("LidgrenNetworkTest"); …Run Code Online (Sandbox Code Playgroud)