/Simple-Random-User-Agent-CSharp

Simple method to generate random User-Agent in CSharp C#

Primary LanguageC#

Random User Agent CSharp

Why? I just don't need external .dll or adding other dependancy, only need 25 lines of code.

GetRandomUserAgent() generate random User-Agent for Firefox, Chrome with OS Window 10, Linux and MacOs

How to Use:

Open simple-random-user-agent.cs and Copy-Paste Line 6-35 To your project file

Compile and Test

Run the following commands:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe simple-random-user-agent.cs
simple-random-user-agent.exe

Output

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.5087.119 Safari/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.5090.158 Safari/537.36