繁体   English   中英

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

[英]Converting some Swift code to C# Xamarin.iOS

如何将这样的一些快速代码转换为C#Xamarin.iOS,请:

警卫让configurationFileURL = Bundle.main.url(forResource:“客户端”,withExtension:“ conf”),让configurationFileContent =尝试? Data(contentsOf:configurationFileURL)else {fatalError()}

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);
}

并回答“与C#相比,Swift加载文件内容好/短得多吗?” 可能不是,但是我没有进行性能测试来验证。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM