public class Devotion { public string Date { get; set; } public string Title { get; set; } public string Verse { get; set; } [JsonProperty("Read Chapter")] public string ReadChapter { get; set; } [JsonProperty("Read Text")] public string ReadText { get; set; } [JsonProperty("Bible In One Year")] public string BibleInOneYear { get; set; } public string Message { get; set; } public string Notes { get; set; } public override string ToString() { string[] props = new string[8]; props[0] = "DATE - " + Date; props[1] = "TITLE - " + Title; props[2] = "VERSE - " + Verse; props[3] = "READ CHAPTER - " + ReadChapter; props[4] = "READ TEXT - " + ReadText; props[5] = "BIBLE IN ONE YEAR - " + BibleInOneYear; props[6] = "MESSAGE - " + Message; props[7] = "NOTES - " + Notes; return String.Join("\r\n\r\n", props); } }
CustomMessageBox cmb; private void openMsgBox(object sender, RoutedEventArgs e) { // create new Stack panel StackPanel sp = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical }; //get policy text from file string devotion = getDevotion("MyDevotion/Devotion1.json"); //Create new label TextBlock tb = new TextBlock() { Text = devotion, TextWrapping = TextWrapping.Wrap, FontSize = 25, }; //Create new Scroll viewer ScrollViewer sv = new ScrollViewer() { VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Height = 700, }; // add texblock in scroll viewer sv.Content = tb; //Add the controls to stack panel sp.Children.Add(sv); cmb = new CustomMessageBox() { // Set its content Content = sp, Opacity = 0.9, // Left button of message box Button LeftButtonContent = "Back", }; //Show the message box... cmb.Show(); } public string getDevotion(string JsonfilePath) { Devotion[] d = null; using (StreamReader r = new StreamReader(JsonfilePath)) { string json = r.ReadToEnd(); d = JsonConvert.DeserializeObject<devotion[]>(json); } return d[0];//**Error here** }
Your getDevotion method is expecting you to return a string but you are trying to return a Devotion.
getDevotion
string
Devotion
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)