What is the C# equivalent of Delphi’s FillChar?
What is the C# equivalent of Delphi’s FillChar ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I understand FillChar correctly, it sets all elements of an array to the same value, yes?
In which case, unless the value is 0, you probably have to loop:
For setting the values to the type’s 0, there is
Array.ClearObviously, with the loop answer you can stick this code in a utility method if you need… for example, as an extension method:
Then you can use:
If you absolutely must have block operations, then
Buffer.BlockCopycan be used to blit data between array locatiosn – for example, you could write the first chunk, then blit it a few times to fill the bulk of the array.