本文整理汇总了C#中MemoryStream.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.ToString方法的具体用法?C# MemoryStream.ToString怎么用?C# MemoryStream.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyMethod
Func<string, string> MyMethod()
{
// If we have a high resource consumption resource, like IDisposable
System.IO.Stream s = new MemoryStream();
// then we should know how Garbage Collector works.
// This "s" is of course defined in this MyMethod() and usually
// Garbage Collector can dispose it when we exit the method.
// But if "s" is captured to a function:
Func<string, string> myfunc = y => y + s.ToString();
// the GC can't dispose it before all the references to
// both MyMethod() and myfunc() are gone.
// This may be not so obvious if the method is async or if I return it away from here:
if (new Random().NextDouble() > 0.6) return myfunc;
// So the point is this: when you do any lambda (not just Func<T>),
// you should know your captured parameters.
// Avoid capturing disposables and large objects like "this".
return h => h;
}