w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Cannot convert object of type 'System.String' to type 'PropertySearch'
It looks like you are trying to deserialize with invalid json. A good place to check your json format is JsonLint.com. You will want your json object to look more like this: { "UserId": 1, "SessionId": 1, "PriceMin": 1, "PriceMax": 1, "BedsMin": 1 } The issue you are having is you are passing a comma delimited string. The deserializer does not know which values to map to which fields.

Categories : Dotnet

asp.net json web service sending array error Cannot convert object of type 'System.String' to type 'System.Collections.Generic.List`1[System.String]'
You need to make your data parameter of the $.ajax call like this: JSON.stringify({'a': variables}) The JSON variable is not available in < IE8 so you'll want to include a JSON implementation like the one mentioned in the answer here Also, you had an extra } in the success function. So, in the future, if you want to add extra parameters to your data object passed to the web service, you'd construct it like so: var someArr = ['el1', 'el2']; JSON.stringify({ 'param1': 1, 'param2': 'two' 'param3': someArr // etc }); JavaScript: var variables = Array(); var i = 0; $('#Div_AdSubmition').find('.selectBox').each(function () { variables[i] = $(this).find('.selected').find(".text").html(); i++; }); $.ajax({ type: 'post', data: JSON.stringify({'a': variables}),

Categories : C#

How to convert String to an object type
Exactly - it will not evaluate object keys. If you want to dynamically create that object as {stars:5} you could do: var obj = {}; obj[type] = term;//Using the array notation will cause JS to evaluate type to "stars" and use that as the key //obj is now {stars:5} App.Response.find(obj);

Categories : Javascript

Convert string to type in object
In order to use Convert the type need to be IConvertible From MSDN For the conversion to succeed, value must implement the IConvertible interface TimeSpan doesn't implement it ... So you can check before calling Convert or add try{} catch{}

Categories : C#

Webgrid: Cannot convert lambda expression to type 'object' because it is not a delegate type
You can't use embedded razor strings within the lambda expression, as @Alessandro D'Andra suggests you have to use x => "<img src='" + someString + "'></img>"; instead. You might also have to wrap it all in an MvcHtmlString to prevent Razor from escaping the string once it is used by the formatter, but I don't know exactly how the formatter works - you have to try it. I made a small test file to find out exactly what the Razor compiler would do with your code. This is the razor file: @{ string someString = "somestring"; Func<object, object> a = x => "<text><img src='" + someString + "'></img></text>"; Func<object, object> b = x => @<text><img src="@someString"></img></text>); } The ASP.NET

Categories : C#

WPF: Cannot convert lambda expression to type 'string' because it is not a delegate type
Your NotifyPropertyChanged expects a string, and you're passing it a delegate. Try: public string SelectedTransactionName { set { if (_selectedTransactionWsName == value) return; this._selectedTransactionWsName = value; // InitializaMessageElement(value.WsMethodName, transactionTypes); InitializaMessageElement(); this.NotifyPropertyChanged("SelectedTransactionName"); this.NotifyPropertyChanged("IsTransactionNameSelected"); } get { return this._selectedTransactionWsName; } }

Categories : Wpf

typeof() when Cannot implicitly convert type 'System.Type' to 'string'
According to the documentation, the DataType property is used to specify an XSD data type, not a .NET type: An XML Schema data type, as defined by the World Wide Web Consortium (www.w3.org) document named "XML Schema Part 2: Datatypes". Try this instead: public class EPubBody { [XmlElement(ElementName = "Image")] public EPubImage[] BodyItems; }

Categories : C#

Actionscript check custom object defined type (not actual type)
I think you're misunderstanding the way all of those examples in your question work. They don't check the type that is associated with a variable - they check the type of the instance assigned to that variable. Here is a good example of why your examples don't make sense: var prop:DisplayObject = new MovieClip(); trace(prop is MovieClip); // true If this worked the way you thought it does, you would actually get false here. All you're doing when you create a variable and give it a type is telling the compiler what type of instances it expects to see assigned to that property, and to throw an error if something that is not an instance of the expected type is assigned to it. I don't think there is a way to determine what type a variable expects. Moreover, I think if you see a need to

Categories : Actionscript

convert String to XML type (Element type)
Your error message gives you a big clue: lineNumber: 1; columnNumber: 911 This means that at position 911 in the input string the parser found <?XML... It appears that your input string contains more than one XML document

Categories : Java

Convert String to Type, where Type is a variable
change Type propertyType = property.GetType(); to Type propertyType = property.PropertyType; Using GetType(), you get the type of property. And property is an instance of PropertyInfo.

Categories : C#

Cannot convert type table-type to 'string'
You query returns x.role_name, which seems to be a string: var y = from x in dbcon.N_Roles_Users where x.user_name == currentUser select x.role_name; That's why you can't assign it to List<Role>. Change your query to select Role entity instead of just role name and it should work. Or change your method declaration to return List<string>: public List<string> GetUserRoles( string currentUser) And change roleslist to be List<string> too: List<string> roleslist = new List<string>();

Categories : C#

JSON Schema: represent constraint to encode object type in string type
I agree, either you choose the object or string type. I have looked into the JSON Schema documentation and I could not find anything to express the constraint as clear as needed. Hence, a short discussions of the two approaches there are to my mind. Type String JSON Schema defines seven primitive types, including object. A string is simply defined as a JSON string. The RFC 4627 defines a JSON string as follows A string is a sequence of zero or more Unicode characters This would apply to your case, even though the content of the string has to be restricted. The question is how to communicate the restriction. I would use a description to reference to another subschema. You can even define a pattern for the string an encode the subschema as regular expression. This, however,

Categories : Javascript

How to cast a string value to some specific type when we have only Class object of the type?
According to what you describe, if you have: String var = "variable"; Class<?> type = Class.forName("your_class");// Your type Object o = type.cast(var); Now 3 things can happen: o should be of your_class type If var is null, o will be null or ClassCastException will be thrown

Categories : Java

convert java type object to string fail for some java types
String is an Object but all the Objects are not Strings. The cast can be to its own class type or to one of its subclass or superclass types or interfaces. There are some rules of Object type casting in Java id it's a primitive type you can do String.valueOf(fieldValue)

Categories : Java

If strings are nullable by default, why do i get Unable to cast object of type 'System.DBNull' to type 'System.String'.?
Because null != DBNull.Value. But you can check if it the value in the DataReader is null with the IsDbNull method: DestributionGroup = dr.IsDbNull("Destribution Group") ? "" : dr.GetString("Destribution Group");

Categories : C#

Unable to cast object of type 'System.Int16' to type 'System.String'
This t.Field<string>("db_code").ToString() perhaps should be this: t.Field<short>("db_code").ToString() or equivalent t.Field<Int16>("db_code").ToString()

Categories : C#

Unable to cast object of type 'System.String[]' to type 'System.IConvertible'
Try this, weight is an array. Assuming you want to convert first element of array. string[] weight = txtProductOptn1.Text.Split(','); var Weight1 = Convert.ToInt32(weight[0]);

Categories : C#

AutoMapper custom type convert using ConstructServicesUsing
I tested this code and got this working using the following code: public void TestMethod1() { Mapper.CreateMap<string, DateTime>().ConvertUsing(new DateTimeTypeConverter()); Mapper.CreateMap<string, Type>().ConvertUsing(new StringTypeConverter()); Mapper.CreateMap<string, int>().ConvertUsing(new StringIntConverter()); Mapper.CreateMap<Source, Destination>(); var destination = Mapper.Map<Source, Destination>( new Source { Value1 = "15", Value2 = "01/01/2000", Value3 = "System.String" }, options => options.ConstructServicesUsing(type => new SourceDestinationTypeConverter()) ); Assert.AreEqual(destination.Value2.Year, 2000); } And the extra Converters: public

Categories : C#

How to implement a type-bound write statement output in a Fortran derived-type or class
You need to have a generic WRITE(FORMATTED) binding, bound to a specific procedure that has suitable characteristics. See section 9.6.4.8 in the F2008 standard for more information. type :: A real :: value integer :: descriptor contains procedure :: writetype generic :: write(formatted) => writetype end type A ... subroutine writetype(dtv, unit, iotype, v_list, iostat, iomsg) ! Argument names here from the std, but you can name them differently. class(A), intent(in) :: dtv ! Object to write. integer, intent(in) :: unit ! Internal unit to write to. character(*), intent(in) :: iotype ! LISTDIRECTED or DTxxx integer, intent(in) :: v_list(:) ! parameters from fmt spec. integer, intent(out) :: iostat ! non zero on error, etc. character(*), int

Categories : Python

"Object of type 'System.object[]' cannot be converted to type 'system.string'"
Using your code, I wrote an example. This is error free and I hope it helps you! static void Main(string[] args) { Dictionary<string, Object> dic = new Dictionary<string, Object>(); dic.Add("tester1", new object()); dic.Add("tester2", new object()); dic.Add("tester3", new object()); dic.Add("tester4", new object()); dic.Add("tester5", new object()); dic.Add("tester6", new object()); Console.WriteLine("Starting loop..."); foreach (KeyValuePair<string, Object> kvp in dic) { var x = kvp.Key; var y = kvp.Value; Console.WriteLine(String.Format("Key: {1}, Value: {2}{0}", Environment.NewLine, x, y)); } Console.WriteLine("Finished Loop

Categories : C#

Convert an Object to a different type, including Lists of the Object
Write your own conversion methods, something like this... public List<CategoryUI> convertArray(List<Category> categoryArray){ List<CategoryUI> convertedArray = new ArrayList<CategoryUI>(); for (int i=0;i<categoryArray.size();i++){ convertedArray.add(convertObject(categoryArray.get(i))); } return convertedArray; } public CategoryUI convertObject(Category category){ return new CategoryUI(category.getId(),category.getName(),convertArray(category.getSubCategory())); } Just call convertObject(category) for each object that you want to convert. You affectively create a new object of the correct type, and populate it with all the data from the old object. It also converts the array of subCategories. If you pass in the top node of your

Categories : Java

How to write an object of unknown type to a binary file?
Simplest approach is to use BinaryFormatter. However you should be very careful with any changes to your classes if you want to load instances saved by previous versions of your application.

Categories : C#

pl/sql: convert cursor type to row object
create or replace type row_t as object(a number, b number); create or replace type table_t is table of row_t; create or replace function func_a return table_t pipelined as v_row_t row_t := row_t(1, 2); begin pipe row (v_row_t); end; / create or replace function func_b(row_in row_t) return number as begin return 3; end; / declare v_row_t row_t; v_result number; begin for c in ( select * from table(func_a()) ) loop v_result := func_b(row_t(c.a, c.b)); end loop; end; /

Categories : Oracle

How to convert object to correct type
If you don't like the last using reflection, you can take advantage of dynamic keyword: var handlerType = typeof (IQueryHandler<,>) .MakeGenericType(query.GetType(), typeof (TResponseData)); dynamic handler = _container.Resolve(handlerType); var resp = new Response<TResponseData>(); resp.Data = (TResponseData) handler.Handle(query);

Categories : C#

convert string to set type
What you can read from a file depends on what's in the file. If you wrote the names of your variables into the file, then you should be able to read them, too. If not, then you can't. Variables names are not inherently written to files when you wrote data, though. Identify the technique used to write the names into your file. To read them, simply perform the inverse operation. If you wrote the data delimited in some way, then read until you encounter a delimiter. If you preceded the name with its character length, then read the length, and then read that many characters. If you didn't write the names with a technique that's invertible, then you'll have to change how you write your data before proceed to reading it. Your question asked whether it was possible to read the names, and the an

Categories : Delphi

What does Failed to convert property value of type '$Proxy0 to required type means in this case?
Ok, first thing i see here: WriterSqlParameterSetter is a ItemPreparedStatementSetter! fine! But even if you declare: <beans:property name="amount" value="#{jobParameters[amount]}"/> <beans:property name="id" value="#{jobParameters[id]}"/> I don't see theses properties in : public class WriterSqlParameterSetter implements ItemPreparedStatementSetter<transactionas>{ public void setValues(transactionas ts, PreparedStatement ps) throws SQLException { ps.setDouble(1, ts.GetAmount()); ps.setInt(2, ts.GetID()); } } And even if the properties were declared, the ItemPreparedStatementSetter wont use them since, it takes value from the object received in the writer (eg. transactionas). I am trying to see why you need to pass an amount and

Categories : Spring

Convert operator from string type to operator type
Evaluate it: result = eval(x + operator + y); EDIT Since you can't use eval, you need to build your own math functions. You can just specify the four functions inside that array (if you don't actually need to know their names), like: myFunctions = [ function(a, b){return a+b;}, function(a, b){return a-b;}, function(a, b){return a/b;}, function(a, b){return a*b;} ]; Then just randomly pick one and call it with your x and y variables as parameters, just like you did before: result = myFunctions[parseInt(Math.random()*4)](x, y);.

Categories : Javascript

What does Failed to convert property value of type '$Proxy0 to required type means?
You don't use the right interface. Your ReaderSqlParameterSetter should implements PreparedStatementSetter not ItemPreparedStatementSetter If you look at the impl of JdbcCursorItemReader: public class JdbcCursorItemReader<T> extends AbstractCursorItemReader<T> { PreparedStatement preparedStatement; PreparedStatementSetter preparedStatementSetter; String sql; RowMapper rowMapper; The property is a PreparedStatementSetter . If you look at the interface you try to use : public interface ItemPreparedStatementSetter<T> { /** * Set parameter values on the given PreparedStatement as determined from * the provided item. * @param ps the PreparedStatement to invoke setter methods on * @throws SQLException if a SQLException is encountered (i.e. there is no * need to

Categories : Spring

Convert String to type of Page?
If you know the fully qualified name of DashBoard - i.e. which assembly and namespace it's in - you can use reflection to determine what to pass to Navigate. Look at the docs for System.Reflection.Assembly, in particular GetTypes and GetExportedTypes, depending on what you need.

Categories : C#

Cannot implicitly convert type string to int
sum = sum + input; //throws an error here should be: sum = sum + inputParsed ; You are using the original input instead of the parsed value. And you don't need sumParsed because you just keep the total sum in sum and you do no need to cast the int to a string and then parse it back to an integer.

Categories : C#

Do Entity Framework Provide Utility that convert DB Type To C# Type?
I dont know such a public method (I think there is none... it that may be accepted as answer) However, try to uncompile sqlmetal.exe, you can have a good idea of how default associations are implemented internally: In class LinqToSqlShared.Utility.DbTypeSystem (internal class) you can find the method: internal static Type GetClosestRuntimeType(SqlDbType sqlDbType) { switch (sqlDbType) { case SqlDbType.BigInt: return typeof(long); case SqlDbType.Binary: case SqlDbType.Image: case SqlDbType.Timestamp: case SqlDbType.VarBinary: return typeof(Binary); case SqlDbType.Bit: return typeof(bool); case SqlDbType.Char: case SqlDbType.NChar: case SqlDbType.NText: case SqlDbType.NVarChar: case SqlDbType.Text: case SqlDbType.

Categories : C#

Different type returned by getter than type of field in Jackson. How to convert map to set?
There is no direct way to convert a Set to a Map. Set is an extension of Collection, Map is an entirely different object. If ContactInfoInterface contains the information you need to manually build a Map you could do that. But trying to pass back a Set in the form of a Map will never work.

Categories : Java

Assign custom object into Object type variable in SSIS
I don't have enough reputation to comment so I'm adding an answer instead. I did the below steps to try and replicate your problem: Created a new script task Created a new class in the namespace of that script Created a variable of type Object and added to script task as Read/Write variable Initialised the new class and assigned that value to the Object variable. Below is my code which ran successfully. Can you please explain if there is any thing I am missing/understanding wrong? using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; namespace ST_8eab6a8fbc79431c8c9eb80339c09d1d.csproj { public class myclass { int a, b; public myclass() { a = 0; b = 0; } } [System.AddIn.AddIn("ScriptMain", Version = "1.0"

Categories : C#

How to convert field of the list item via custom struts type converter?
TypeConversion Annotation: This annotation is used for class and application wide conversion rules. The TypeConversion annotation can be applied at property and method level. @TypeConversion(converter = “com.test.struts2.MyConverter”) public void setAmount(String amount) { this.amount = amount; } This annotation specifies the location of one of my converters. literally, by using this annotation, I register my class com.test.struts2.MyConverter as a converter, and gets executed every time when setAmount(String amount) method is invoked.

Categories : Java

convert selected item back to custom data type, winforms
Try listview1.Columns.Add("Col1"); listview1.Columns.Add("Col2"); foreach(ArticleDetails ad in myCollection) { var row = new ListViewItem(ad.Article.Name); row.Tag = ad; // You can use this to store your object row.SubItems.Add(ad.Article.Price); } listview1.View = View.Details; private void btnDelete_Click(object sender, EventArgs e) { var selected = (CustomDataType)listview1.SelectedItems[0].Tag; }

Categories : C#

Cannot implicity convert type object to unityengine.Vector3
Since you're using an ArrayList the vectors are being stored as objects. Try this ball.transform.position = (Vector3)coordinateContainer[i]; You may be better off with List<Vector3> instead of an ArrayList so that you can avoid the casting (as List<T> can only hold objects of type T).

Categories : C#

Convert "C# friendly type" name to actual type: "int" => typeof(int)
Alias names like 'int','bool' etc. are not part of .NET Framework. Internally they are converted into System.Int32, System.Boolean etc. Type.GetType("int") should return you null. Best way to appoach this is by having a dictionary to map alias with their type e.g. Dictionary<string, Type> PrimitiveTypes = new Dictionary<string, Type>(); PrimitiveTypes.Add("int", typeof(int)); PrimitiveTypes.Add("long", typeof(long)); etc.etc..

Categories : C#

c++ std::map asignation error : cannot convert ' type **' to 'type *' in assignment
void findMessageId(R * aPointerType,const int & aPKValue, int & aResult) { if (aPKValue < 0) { aResult=-1; return; } //buscar valor dentro de la lista mMessageListIterador=mListMessage->find(aPKValue); if (mMessageListIterador!=mListMessage->end()) { aResult=0; aPointerType=&mMessageListIterador->second; } else aResult=-1; return; } In this method i changed this line: aPointerType=&mMessageListIterador->second; for this: aPointerType=mMessageListIterador->second;

Categories : C++

scala convert String to generic type
Take a look at marshalling/unmarshalling as implemented in Spray. You may not need to reinvent the solution, and if you do, you can take a look at their source to see how they've implemented it. Spray's marshalling/unmarshalling is similar to object graph serialization and works with more than just JSON so there's some additional inherent complexity within the implementation. You could also get around manually parsing JSON and try lift-json. lift-json is closer to JSON though through extract it can operate similar to Spray's marshaller/unmarshaller.

Categories : Scala

If I have a type defined as a string constant, why can't I pass that type to functions as an actual string?
In the first case, you're passing strings, no problem. In the second one, you pass StringType values instead of strings. You need to tell the compiler they're strings by converting them : Replace return strings.Contains(a, b) with return strings.Contains(string(a), string(b))

Categories : Go



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.