How I can translate this code to C# properly, I know even if there are some similarities between C# and Java, as well this not means everything is 1:1, and my experience with I/