我怎样才能将一些SWIFT这样的代码到C#Xamarin.iOS请:
守卫让configurationFileURL = Bundle.main.url(forResource: “客户端”,withExtension: “CONF”),让configurationFileContent =试试?数据(contentsOf:configurationFileURL)其他{fatalError()}
是斯威夫特好多/短加载比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#中的文件内容?”或许不会,但我没有做性能测试来验证。