Where do I put my extension method?

后端 未结 4 1223
我寻月下人不归
我寻月下人不归 2021-01-01 10:34

A senior member here gave me this code:

public static string Truncate(this string value, int maxChars)
{
    return value.Length <= maxChars ? value : val         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 10:49

    Yes, use a static class. I organize in a separate project that I can use across solutions. I also organize in separate files grouped by what I'm extending such as strings, enums, io, datetime, etc

提交回复
热议问题