下面一段程序怎样转为c#?
function valid(prestring)
Dim texts
Dim seed
Dim i,length
prestring = trim(preString)
length = len(preString)
seed = length
Randomize(length)
texts = ""
seed = int(95*rnd(-asc(mid(preString,i,1))-seed*asc(right(prestring,1)))+32)
texts = chr(seed)
texts = Replace(texts,"'","")
texts = Replace(texts,"""","")
valid = texts
end function
这是一段asp程序,用c#应该怎样写?请大侠指教