none
c# method error CS1056 RRS feed

  • Question

  • Hi,

    When i am executing MSBuild I am facing issue "error CS1056: Unexpected character '$' " in the below method.  please provide inputs to use string.Format in the method instead of  $  to solve the issue.

     public static string AdjustHourMinutes(this string sender)
            {
    
                if (!sender.Contains(":"))
                {
                    return sender.Length == 1 ? $"0{sender}:00" : $"{sender}:00";
                }
                else
                {
                    var parts = sender.Split(':');
                    return parts[1].Length == 2 ? $"{Convert.ToInt32(parts[0]):D2}:{parts[1]}" : 
                        $"{Convert.ToInt32(parts[0]):D2}:0{parts[1]}";
                }
            }

    Thank you.


    Vamshi Janagama

    Tuesday, December 17, 2019 3:39 AM

Answers

All replies