System.IO.TextWriter.Write C# (CSharp) Method

Write() public method

public Write ( object value ) : void
value object
return void
        public virtual void Write(object value)
        {
            if (value != null)
            {
                IFormattable f = value as IFormattable;
                if (f != null)
                {
                    Write(f.ToString(null, FormatProvider));
                }
                else
                    Write(value.ToString());
            }
        }

Same methods

TextWriter::Write ( bool value ) : void
TextWriter::Write ( char value ) : void
TextWriter::Write ( char buffer, int index, int count ) : void
TextWriter::Write ( decimal value ) : void
TextWriter::Write ( double value ) : void
TextWriter::Write ( float value ) : void
TextWriter::Write ( int value ) : void
TextWriter::Write ( long value ) : void
TextWriter::Write ( string value ) : void
TextWriter::Write ( string format, object arg0 ) : void
TextWriter::Write ( string format, object arg0, object arg1 ) : void
TextWriter::Write ( string format, object arg0, object arg1, object arg2 ) : void
TextWriter::Write ( uint value ) : void
TextWriter::Write ( ulong value ) : void

Usage Example

Exemplo n.º 1
0
	/**
	 * Prettyprint the object to the outputstream.
	 */
	public static void print(object o, TextWriter w, bool typeheader) {
		if (o == null) {
			if(typeheader) w.WriteLine("null object");
			w.WriteLine("null");
			w.Flush();
			return;
		}

		if (o is IDictionary) {
			if(typeheader) w.WriteLine("hashtable");
			IDictionary map=(IDictionary)o;
			w.Write("{");
			foreach(object key in map.Keys) {
				w.Write(key.ToString()+"="+map[key].ToString()+", ");
			}
			w.WriteLine("}");
		} else if (o is string) {
			if(typeheader) w.WriteLine("String");
			w.WriteLine(o.ToString());
		} else if (o is DateTime) {
			if(typeheader) w.WriteLine("DateTime");
			w.WriteLine((DateTime)o);
		} else if (o is IEnumerable) {
			if(typeheader) w.WriteLine(o.GetType().Name);
			writeEnumerable(o, w);
			w.WriteLine("");
		} else {
			if(typeheader) w.WriteLine(o.GetType().Name);
			w.WriteLine(o.ToString());
		}
		
		w.Flush();
	}
All Usage Examples Of System.IO.TextWriter::Write