Explorar o código

加入靜態方法讀取字串

kangkangtm %!s(int64=3) %!d(string=hai) anos
pai
achega
9ee4c3dd94
Modificáronse 1 ficheiros con 16 adicións e 1 borrados
  1. 16 1
      KdanStrings/Class1.cs

+ 16 - 1
KdanStrings/Class1.cs

@@ -3,10 +3,25 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Windows.ApplicationModel.Resources;
 
 namespace KdanStrings
 {
-    public class Class1
+    public class Localized
     {
+        public string this[string key]
+        {
+            get
+            {
+                var str = ResourceLoader.GetForViewIndependentUse("KdanStrings/Resources").GetString(key);
+                return str;
+            }
+        }
+
+        public static string GetString(string key)
+        {
+            return ResourceLoader.GetForViewIndependentUse("KdanStrings/Resources").GetString(key);
+        }
     }
+
 }