© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
6 replies
n8ta

✅ How does this code call System.Text.StringBuilder.ToString?

        public bool PersistSettings()
        {
            bool succeeded = false;

            try
            {
                lock (thisLock)
                {
                    if (!hasChanges)
                    {
                        return true;
                    }

                    BackupSettingsFile();

                    using (StreamWriter writer = new StreamWriter(settingsFile))
                    {
                        writer.Write(JsonConvert.SerializeObject(settings));
                    }

                    hasChanges = false;
                    succeeded = true;
                }
            }
            catch (Exception e)
            {
                RestoreSettingsFile();
            }

            return succeeded;
        }
        public bool PersistSettings()
        {
            bool succeeded = false;

            try
            {
                lock (thisLock)
                {
                    if (!hasChanges)
                    {
                        return true;
                    }

                    BackupSettingsFile();

                    using (StreamWriter writer = new StreamWriter(settingsFile))
                    {
                        writer.Write(JsonConvert.SerializeObject(settings));
                    }

                    hasChanges = false;
                    succeeded = true;
                }
            }
            catch (Exception e)
            {
                RestoreSettingsFile();
            }

            return succeeded;
        }

I've grabbed stacks of my program at runtime and I can see it in the PersistSettings method and then above that on the stack is System.Text.StringBuilder.ToString. Can anyone tell where that method could be inserted by the compiler?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Stringbuilder remove
C#CC# / help
3y ago
Appending to StringBuilder by Unicode code point?
C#CC# / help
11mo ago
✅ StringBuilder in C#
C#CC# / help
12mo ago
✅ Where does the extra linebreak come from (StringBuilder)?
C#CC# / help
2y ago