View RestSharp.TwitterClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.Json.Serialization; | |
using RestSharp.Authenticators; | |
namespace RestSharp.Tests.External.Twitter; | |
public interface ITwitterClient | |
{ | |
Task<TwitterUser> GetUser(string user); | |
} |
View FormatarCpfSpan.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ReadOnlySpan<char> FormatarCpf(string cpf) | |
{ | |
Span<char> formattedValue = stackalloc char[14]; | |
Copy(cpf, startIndex: 0, length: 3, ref formattedValue, insertIndex: 0); | |
formattedValue[3] = '.'; | |
Copy(cpf, startIndex: 3, length: 3, ref formattedValue, insertIndex: 4); | |
formattedValue[7] = '.'; |
View FormatarCpfInt.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string FormatarCpf(string cpf) | |
{ | |
return Convert.ToUInt64(cpf).ToString(@"000\.000\.000\-00"); | |
} |
View FormatarCpfSubstring.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string FormatarCpf(string cpf) | |
{ | |
// cpf: 12345678909 | |
return $"{cpf.Substring(0, 3)}." + // 123. | |
$"{cpf.Substring(3, 3)}." + // 456. | |
$"{cpf.Substring(6, 3)}-" + // 789- | |
$"{cpf.Substring(9, 2)}"; // 09 | |
// resultado: 123.456.789-09 |