Class ObjectExtension
Extensions for object.
Inheritance
System.Object
ObjectExtension
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StoneCo.Framework.Extension
Assembly: cs.temp.dll.dll
Syntax
public static class ObjectExtension
Methods
ToByteArray(Object)
Get the byte array.
Declaration
public static byte[] ToByteArray(this object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Generic object to convert in array of bytes. |
Returns
Type | Description |
---|---|
System.Byte[] | Byte array. |
Examples
Foo class used in this example.
public class Foo
{
public int IdFoo { get; set; }
public string Name { get; set; }
public string Code { get; set; }
}
Bar class used in this example.
public class Bar
{
public byte[] GetByteArray()
{
var foo = new Foo
{
IdFoo = 1,
Name = "Stone Co",
Code = "STNE"
};
return foo.ToByteArray();
}
}
ToQueryString(Object)
Get the query string with properties of the object.
Declaration
public static string ToQueryString(this object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Generic object with properties to get the query string. |
Returns
Type | Description |
---|---|
System.String | Query string |
Examples
Foo class used in this example.
public class Foo
{
public int IdFoo { get; set; }
public string Name { get; set; }
public string Code { get; set; }
}
Bar class used in this example.
public class Bar
{
public string GetQueryString()
{
var foo = new Foo
{
IdFoo = 1,
Name = "Stone Co",
Code = "STNE"
};
return foo.ToQueryString();
}
}
The result in this sample is...
"IdFoo=1&Name=Stone+Co&Code=STNE"
ToQueryStringAsync(Object)
Get the query string with properties of the object.
Declaration
public static Task<string> ToQueryStringAsync(this object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Generic object with properties to get the query string. |
Returns
Type | Description |
---|---|
Task<System.String> | Query string |
Examples
Foo class used in this example.
public class Foo
{
public int IdFoo { get; set; }
public string Name { get; set; }
public string Code { get; set; }
}
Bar class used in this example.
public class Bar
{
public async Task<string> ToQueryStringAsync()
{
var foo = new Foo
{
IdFoo = 1,
Name = "Stone Co",
Code = "STNE"
};
return await foo.ToQueryStringAsync();
}
}
The result in this sample is...
"IdFoo=1&Name=Stone+Co&Code=STNE"