Use ToString("X4")
.
The 4 means that the string will be 4 digits long.
Reference: The Hexadecimal (“X”) Format Specifier on MSDN.
More Related Contents:
- Trim String to int, then char to string, Listbox to textbox
- Calculate relative time in C#
- How to register multiple implementations of the same interface in Asp.Net Core?
- Cancellation token in Task constructor: why?
- When should I use “using” blocks in C#? [duplicate]
- Escape command line arguments in c#
- Format a date in XML via XSLT
- How to check if IEnumerable is null or empty?
- How to detect when a windows form is being minimized?
- How do I get around the “‘” problem in sqlite and c#?
- Is there any JSON Web Token (JWT) example in C#?
- How to run multiple SQL commands in a single SQL connection?
- How to change listview selected row backcolor even when focus on another control?
- Why am I getting ‘One or more types required to compile a dynamic expression cannot be found.’?
- Dynamic button creation & placing them in a predefined order using c#
- How can I embed any file type into Microsoft Word using OpenXml 2.0
- DateTime column type becomes String type after deserializing DataTable
- Close button for TabPages of Right To Left TabControl c#
- Find out the control with last focus
- List sort based on another list
- Generics: Why can’t the compiler infer the type arguments in this case?
- Asynchronous Controller is blocking requests in ASP.NET MVC through jQuery
- Load a ResourceDictionary from an assembly
- ItemPropertyChanged not working on observableCollection.Why?
- Make DateTimePicker work as TimePicker only in WinForms
- AutoMapper Migrating from static API
- TableLayoutPanel responds very slowly to events
- How to receive event when user changes system’s culture
- Modelling polymorphic associations database-first vs code-first
- Is Injection Possible through Dynamic LINQ?