Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将一些Swift代码转换为C#Xamarin.iOS_C#_Swift_Xamarin_Xamarin.ios_Porting - Fatal编程技术网

将一些Swift代码转换为C#Xamarin.iOS

将一些Swift代码转换为C#Xamarin.iOS,c#,swift,xamarin,xamarin.ios,porting,C#,Swift,Xamarin,Xamarin.ios,Porting,我如何将一些像这样的swift代码转换为C#Xamarin.iOS请: 卫兵 让configurationFileURL=Bundle.main.url(对于资源:“client”,扩展名为:“conf”), 让configurationFileContent=试试?数据(内容:配置文件URL) 否则{ 法塔莱罗() } Swift加载文件内容是否比C#好/短得多?谢谢请尝试以下操作: // Get the path to the resource file var configurationF

我如何将一些像这样的swift代码转换为C#Xamarin.iOS请:

卫兵 让configurationFileURL=Bundle.main.url(对于资源:“client”,扩展名为:“conf”), 让configurationFileContent=试试?数据(内容:配置文件URL) 否则{ 法塔莱罗() }

Swift加载文件内容是否比C#好/短得多?谢谢

请尝试以下操作:

// Get the path to the resource file
var configurationFileURL = NSBundle.MainBundle.PathForResource("client", "conf");
// Make sure the file exists 
if (configurationFileURL != null)
{
    // load the text content of the file into a string variable declared elsewhere
    configurationFileContent = File.ReadAllText(configurationFileURL);
}
并回答“Swift加载文件内容是否比C#好/短得多?”
可能没有,但我还没有做性能测试来验证。

var data=File.ReadAllText(路径);非常感谢,还有一个关于func的问题……这些是常规方法还是事件处理程序,以及如果它们是扩展适配器的一部分,如何进行移植Tests:AdapterDelegate和命名类似于此func适配器(Adapter:Adapter,configureTunnelWithNetworkSettings networkSettings:NEPacketTunnelNetworkSettings,completionHandler:@escaping(AdapterPacketFlow?->Void)和func Adapter(Adapter:Adapter,handleEvent event:AdapterEvent,message:String?),因为它们都具有不同于C#中接受发送方和事件参数(或派生的内容)的事件处理程序的签名。请为有关funcs的问题提出一个新问题。感谢您的帮助,下面是我可能有点过火的后续问题(但我也想尝试自己做一些工作,而不仅仅是纠缠其他人)。无论如何,提前谢谢。