Questions tagged [typeconverter]

TypeConverters provide the means for converting values to other types. In .NET,TypeConverters are bound to a Type (class) and the most common conversion is to and from string. One of the primary uses for them is to provide a text representation of a class instance for use by designer serialization or for display in property grids.

519 questions
51
votes
1 answer

How to convert NSMutableData to NSString on iPhone?

I received an NSMutableData from a server and now I want to convert it to an NSString. Any ideas about how to do this?
Chilly Zhong
  • 16,373
  • 23
  • 75
  • 103
44
votes
1 answer

Generic conversion function doesn't seem to work with Guids

I have the following code: public static T ParameterFetchValue(string parameterKey) { Parameter result = null; result = ParameterRepository.FetchParameter(parameterKey); return (T)Convert.ChangeType(result.CurrentValue, typeof(T),…
mattruma
  • 16,084
  • 31
  • 98
  • 163
38
votes
1 answer

ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor

I'm trying to get an overall understanding of how you use ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor to change how a PropertyGrid displays and interfaces with an object. Can someone tell me if this is right, or…
Eric Anastas
  • 20,455
  • 32
  • 134
  • 223
26
votes
2 answers

Convert double to string

i have three double variable a ,b and c a = 0.000006 b = 6 c = a/b; so C should be 0.000001 i want to show this value in text box so i wrote textbox.text = c.tostring(); but it's give result as "1E-06".. Can anybody help me out how can i put…
Kartik
  • 561
  • 5
  • 15
  • 31
23
votes
5 answers

Convert binary string to binary or decimal value

Is there any function to convert binary string into binary or decimal value? If I have a binary string 000101, what should I do to convert it into 5?
LifeWorks
  • 356
  • 1
  • 3
  • 11
22
votes
3 answers

Can I convert embedded base64 encode font to a font file?

I have an @font-face rule, and its look like this: @font-face{ font-family:'F'; src:url("") format("embedded-opentype"), url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAA ... ETC... ETC Can i convert this to a font file? Thanks!
mauriblint
  • 1,536
  • 2
  • 21
  • 43
19
votes
3 answers

Newtonsoft.JSON cannot convert model with TypeConverter attribute

I have an C# MVC application which stores data as JSON strings in an XML document and also in MySQL DB Tables. Recently I have received the requirement to store JSON strings in MySQL Database fields, to be converted into C# objects via…
Steve
  • 359
  • 1
  • 2
  • 13
19
votes
1 answer

Proper way of converting string to long int in PHP

I tried (int) "4209531264" and intval("4209531264") but sadly all I get is 2147483647 (I realize this is because of 32 bit architecture or some php dependencies or something). I came up with "4209531264" + 0 which returns the correct result but it…
Maciej Jankowski
  • 2,604
  • 3
  • 23
  • 33
19
votes
3 answers

The TypeConverter for "FontWeight" does not support converting from a string

After installing Visual Studio 2012 and opening a Silverlight 5 project I'm getting various design time errors related to TypeConverter, such as: The TypeConverter for "FontWeight" does not support converting from a string. The TypeConverter for…
17
votes
6 answers

How can I convert a key code into a char or string?

How to convert the keycode into char or string?? Here is the example code: public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub //Log.d("EditText", "It's Working...!" + event.getAction()); if…
ram
  • 3,377
  • 9
  • 31
  • 47
17
votes
2 answers

Inconsistency in TypeConverter behavior?

I am working on an IValueConverter implementation which would convert bool? values. For the sake of versatility I've decided to use TypeConverter to convert input value to bool?. Since its main purpose is to be used as a converter for XAML bindings…
Grx70
  • 9,261
  • 1
  • 33
  • 51
17
votes
2 answers

Cannot create a TypeConverter for a generic type

I'd like to create a TypeConverter for a generic class, like this: [TypeConverter(typeof(WrapperConverter))] public class Wrapper { public T Value { // get & set } // other methods } public class WrapperConverter :…
tcarvin
  • 10,293
  • 3
  • 27
  • 50
16
votes
1 answer

TypeConverter Attribute for Third Party Classes

When creating a class, a TypeConverter attribute can be applied to it s.t. using TypeDescriptor.GetConverter(typeof(T)) return the custom type converter. For instance: [TypeConverter(typeof(FooConverter))] public class Foo {...} public class…
TRISAbits
  • 445
  • 4
  • 9
15
votes
3 answers

Enumeration to boolean casting question

I have the following enumeration: public enum MyEnum { MyTrue, MyFalse } And I'd like to eventually be able to automatically convert my enumeration to a boolean value, with a simple line like this: MyEnum val = MyEnum.MyTrue; bool…
greggorob64
  • 2,351
  • 2
  • 26
  • 52
14
votes
2 answers

Can you assign a TypeConverter without a TypeConverterAttribute?

Dependency requirements are forcing me to have a class and its TypeConverter in different assemblies. Is there a way to assign a TypeConverter to a class without using a TypeConverterAttribute, and thus causing circular assembly references. Thanks.
Spike
  • 2,026
  • 12
  • 27
1
2 3
34 35