Click here to Skip to main content
12,998,785 members (70,961 online)
Click here to Skip to main content


Posted 29 Mar 2010

How to remove NULL byte from String in C#

, 29 Mar 2010
string result = input.Replace("\0", string.Empty);However, as you have already been told, using Unicode UTF16 is a bad idea. If you really need Unicode, you should use UTF8 instead.



Compare Revision Minor Date Status Editor
2 - publicly available No 29-Mar-10 4:51 Available Toli Cuturicu
1 No 29-Mar-10 4:49 Composing Toli Cuturicu


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Toli Cuturicu
Software Developer
Romania Romania
I started programming a ZX Spectrum in 1985 using Spectrum Basic (arghh) and Z80 assembler.
I switched to pascal and 80286 assembler in 1992.
From about 1999 I began using Delphi.
Pascal and Delphi will always remain close to my soul.
I learned a little C and C++ for my linux machine, but always hated it!
I graduated Chemistry in 1997 (Master in 1999) but I never used it.
I had to learn C# and SQL when I first got employed in IT in 2005 and I do not regret it.
I like C# a lot and I do warmly recommend it.

I use Windows 7 and Windows XP, Internet Explorer 9, Visual Studio 2005 and 2010, Paint.NET, Firebird SQL etc.

I am currently mainly programming Windows Applications in C# using Windows Forms.

I am Romanian and I live in Romania, but I visited lots of countries and learned many foreign languages.

I want to know stuff so I read a lot.
I like to ski and to play table tennis.
I play decent chess, backgammon, bridge and many other games. And, since I like board and card games, I also like to program them, of course.
I like to program for fun and I have lots of projects and not enough time to pursue them.

More? I don't think so. If you've got so far you are probably already bored.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 29 Mar 2010
Article Copyright 2010 by Toli Cuturicu
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid