将一些 Swift 代码转换为 C# Xamarin.iOS
Converting some Swift code to C# Xamarin.iOS
请问如何将一些 swift 代码转换为 C# Xamarin.iOS:
guard
let configurationFileURL = Bundle.main.url(forResource: "client", withExtension: "conf"),
let configurationFileContent = try? Data(contentsOf: configurationFileURL)
else {
fatalError()
}
Swift加载一个文件内容比C#多better/shorter吗?谢谢
尝试以下操作:
// 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);
}
并回答 "Is Swift so much better/shorter to load a file content than C#?"
应该不会,不过我没有做过性能测试来验证。
请问如何将一些 swift 代码转换为 C# Xamarin.iOS:
guard let configurationFileURL = Bundle.main.url(forResource: "client", withExtension: "conf"), let configurationFileContent = try? Data(contentsOf: configurationFileURL) else { fatalError() }
Swift加载一个文件内容比C#多better/shorter吗?谢谢
尝试以下操作:
// 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);
}
并回答 "Is Swift so much better/shorter to load a file content than C#?" 应该不会,不过我没有做过性能测试来验证。