Search Results

Search found 763 results on 31 pages for 'casting'.

Page 9/31 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Object C casting

    - by ct2k7
    Hi, I'm trying to cast this statement: [self handError:noConnectionError]; basically, this statement is in a class, which is not the app delegate, but is the .m file of a view, specifically a view after uitableview, which contains its own uiviewtable. The warning that statement gives me is that the error produced may not be apparent to the UIView (view control container).

    Read the article

  • Service Broker message_body error when casting binary data to xml in C#

    - by TimBuckTwo
    I am using Message Broker with Sql server 2008, and designing an External Activator service to consume messages from my target queue. My Problem: Cant cast the returned message body from the SqlDataReader object: "WAITFOR (RECEIVE TOP(1) conversation_handle, message_type_name, message_body FROM [{1}]), TIMEOUT {2}" operation, I cant cast the binary data to XML in C# SqlBinary MessageBody = reader.GetSqlBinary(2); MemoryStream memstream = new MemoryStream(); XmlDocument xmlDoc = new XmlDocument(); memstream.Write(MessageBody.Value, 0, MessageBody.Length); memstream.Position= 0; //below line Fails With Error:{"Data at the root level is invalid. Line 1, position 1."} xmlDoc.LoadXml(Encoding.ASCII.GetString(memstream.ToArray())); memstream.Close(); To prevent poison message I do not use CAST(message_body as XML), Any suggestions would be greatly appreciated.

    Read the article

  • casting needed?

    - by Joo Park
    what is the difference between these two lines of code? Is there a difference? NSManagedObject* object = (NSManagedObject*)[self.fetchedResults objectAtIndexPath:indexPath]; NSManagedObject* object = [self.fetchedResults objectAtIndexPath:indexPath];

    Read the article

  • C# Reflection - Casting private Object field

    - by alhazen
    I have the following classes: public class MyEventArgs : EventArgs { public object State; public MyEventArgs (object state) { this.State = state; } } public class MyClass { // ... public List<string> ErrorMessages { get { return errorMessages; } } } When I raise my event, I set 'State' of the MyEventArgs object to an object of type MyClass. I'm trying to retrieve ErrorMessages by reflection in my event handler: public static void OnEventEnded(object sender, EventArgs args) { Type type = args.GetType(); FieldInfo stateInfo = type.GetField("State"); PropertyInfo errorMessagesInfo = stateInfo.FieldType.GetProperty("ErrorMessages"); object errorMessages = errorMessagesInfo.GetValue(null, null); } But this returns errorMessagesInfo as null (even though stateInfo is not null). Is it possible to retrieve ErrorMessages ? Thank you

    Read the article

  • casting, converting, and input from textbox controls

    - by Matt
    Working on some .aspx.cs code and decided I would forget how to turn a textbox value into a useable integer or decimal. Be warned I'm pretty new to .asp. Wish I could say the same for c sharp. So the value going into my textbox (strawberryp_textbox) is "1" which I presume I can access with the .text property. Which I then parse into a int. The Error reads Format Exception was unhandled by user code. My other question is can I do operations on a session variable? protected void submit_order_button_Click(object sender, EventArgs e) { int strawberryp; int strawberrys; decimal money1 = decimal.Parse(moneybox1.Text); decimal money2 = decimal.Parse(moneybox2.Text); decimal money3 = decimal.Parse(moneybox3.Text); decimal money4 = decimal.Parse(moneybox4.Text); decimal money5 = decimal.Parse(moneybox5.Text); strawberryp = int.Parse(strawberryp_Textbox.Text); //THE PROBLEM RIGHT HERE! strawberrys = int.Parse(strawberrys_Textbox.Text); // Needs fixed int strawberryc = int.Parse(strawberryc_Textbox.Text); //fix int berryp = int.Parse(berryp_Textbox.Text); //fix int raspberryp = int.Parse(raspberryp_Textbox.Text); /fix decimal subtotal = (money1 * strawberryp) + (money2 * strawberrys) + (money3 * strawberryc) + (money4 * berryp) + (money5 * raspberryp); //check to see if you can multiply decimal and int to get a deciaml!! Session["passmysubtotal"] = subtotal; //TextBox2.Text; (strawberryp_Textbox.Text);//TextBox4.Text; add_my_order_button.Enabled = true; add_my_order_button.Visible = true; submit_order_button.Enabled = false; submit_order_button.Visible = false; strawberryp_Textbox.ReadOnly = false; strawberrys_Textbox.ReadOnly = false; strawberryc_Textbox.ReadOnly = false; berryp_Textbox.ReadOnly = false; raspberryp_Textbox.ReadOnly = false; Response.Redirect("reciept.aspx"); } Thanks for the help

    Read the article

  • casting variables to movie clip

    - by user16458
    How i can convert gecko object to a movie clip function finish(boxname, arrayname:Array):void { for each (var item:String in arrayname) { trace(boxname+"_"+item); var gecko:MovieClip = (boxname+"_"+item) as MovieClip ; trace(typeof(gecko)); gecko.gotoAndPlay("glow"); } } i get the following error high_hsymbol_1 object TypeError: Error #1009: Cannot access a property or method of a null object reference. at quizz_fla::MainTimeline/finish() at quizz_fla::MainTimeline/dropIt()

    Read the article

  • Dynamically Casting In ActionScript

    - by Joshua
    Is there a way to cast dynamically in Actionscript? What I want to accomplish is illustrated by the following code: var Val:*; var S:String=SomeTextEdit.text; switch (DesiredTypeTextEdit.text) { case 'int':Val=int(S);break; case 'uint':Val=uint(S);break; case 'String':Val=String(S);break; case 'Number':Val=Number(S);break; ... } SomeDisplayObject[SomePropertyNameTextEdit.text]=Val; I am looking for something LIKE the following PSEUDOCODE: SomeDisplayObject[SomePropertyName]=eval(DesiredType)(SomeTextEdit.text); Yes, I already realize that "eval" is not on the table, nor is that how one would use it. What's the RIGHT way?

    Read the article

  • current_date casting

    - by Armen Mkrtchyan
    Hi. string selectSql = "update " + table + " set state_" + mode + "_id=1 WHERE stoping_" + mode + " < current_date;"; when i call current_date, it return yyyy-MM-dd format, but i want to return dd.MM.yyyy format, how can i do that. please help. my program works fine when i am trying string selectSql = "update " + table + " set state_" + mode + "_id=1 WHERE stoping_" + mode + " < '16.04.2010';";

    Read the article

  • C++: casting to void* and back

    - by MInner
    * ---Edit - now the whole sourse* When I debug it on the end, "get" and "value" have different values! Probably, I convert to void* and back to User the wrong way? #include <db_cxx.h> #include <stdio.h> struct User{ User(){} int name; int town; User(int a){}; inline int get_index(int a){ return town; } //for another stuff }; int main(){ try { DbEnv* env = new DbEnv(NULL); env->open("./", DB_CREATE | DB_INIT_MPOOL | DB_THREAD | DB_INIT_LOCK | DB_INIT_TXN | DB_RECOVER | DB_INIT_LOG, 0); Db* datab = new Db(env, 0); datab->open(NULL, "db.dbf", NULL, DB_BTREE, DB_CREATE | DB_AUTO_COMMIT, 0); Dbt key, value, get; char a[10] = "bbaaccd"; User u; u.name = 1; u.town = 34; key.set_data(a); key.set_size(strlen(a) + 1 ); value.set_data((void*)&u); value.set_size(sizeof(u)); get.set_flags(DB_DBT_MALLOC); DbTxn* txn; env->txn_begin(NULL, &txn, 0); datab->put(txn, &key, &value, 0); datab->get(txn, &key, &get, 0); txn->commit(0); User g; g = *((User*)&get); printf("%d", g.town); getchar(); return 0; }catch (DbException &e){ printf("%s", e.what()); getchar(); } solution create a kind of "serializator" what would convert all POD's into void* and then will unite these pieces PS Or I'd rewrite User into POD type and everything will be all right, I hope. Add It's strange, but... I cast a defenetly non-pod object to void* and back (it has std::string inside) and it's all right (without sending it to the db and back). How could it be? And after I cast and send 'trough' db defenetly pod object (no extra methods, all members are pod, it's a simple struct {int a; int b; ...}) I get back dirted one. What's wrong with my approach? Add about week after first 'add' Damn... I've compiled it ones, just for have a look at which kind of dirt it returnes, and oh! it's okay!... I can't ! ... AAh!.. Lord... A reasonable question (in 99.999 percent of situations right answer is 'my', but... here...) - whos is this fault? My or VSs?

    Read the article

  • scala Slider throws casting exception

    - by coubeatczech
    hello, I create an Slider object: val slider = new Slider{ min = 0 max = 30 labels = Map(0 -> new Label("Nula"),15-> new Label("Pul"),30-> new Label("Max")) paintLabels = true } when I run this, an exception is thrown: scala.swing.Label cannot be cast to java.awt.Component but why? When i browse the docs, the excpected type for labels is a Map[Int,Label].

    Read the article

  • Casting array of pointers to objects

    - by ritmbo
    If B is subclass of A. And I have in main(): B** b = new B*[10]; ... some algorithm that do b[i] = new B(..); ... So I have an array of pointers to objets B. Then I have a function: void f(A** foo); If in main, I do: f(b); I get a warning, but obviously if I do: f((A**)b);, i dont. The (A**) its a bit nasty. I was wondering if there's a more elegant way in C++ that at least do type checking as dynamic_cast.

    Read the article

  • Casting to specify unknown object type?

    - by fuzzygoat
    In the following code I have a view object that is an instance of UIScrollView, if I run the code below I get warnings saying that "UIView might not respond to -setContentSize etc." UIImage *image = [UIImage imageNamed:@"Snowy_UK.jpg"]; imageView = [[UIImageView alloc] initWithImage:image]; [[self view] addSubview:imageView]; [[self view] setContentSize:[image size]]; [[self view] setMaximumZoomScale:2.0]; [[self view] setMinimumZoomScale: [[self view] bounds].size.width / [image size].width]; I have checked the type of the object and [self view] is indeed a UIScrollView. I am guessing that this is just the compiler making a bad guess as to the type and the solution is simply to cast the object to the correct type manually, am I getting this right? UIScrollView *scrollView = (UIScrollView *)[self view]; UIImage *image = [UIImage imageNamed:@"Snowy_UK.jpg"]; imageView = [[UIImageView alloc] initWithImage:image]; [[self view] addSubview:imageView]; [scrollView setContentSize:[image size]]; [scrollView setMaximumZoomScale:2.0]; [scrollView setMinimumZoomScale: [scrollView bounds].size.width / [image size].width]; cheers Gary.

    Read the article

  • .net runtime type casting when using reflection

    - by Mike
    I have need to cast a generic list of a concrete type to a generic list of an interface that the concrete types implement. This interface list is a property on an object and I am assigning the value using reflection. I only know the value at runtime. Below is a simple code example of what I am trying to accomplish: public void EmployeeTest() { IList<Employee> initialStaff = new List<Employee> { new Employee("John Smith"), new Employee("Jane Doe") }; Company testCompany = new Company("Acme Inc"); //testCompany.Staff = initialStaff; PropertyInfo staffProperty = testCompany.GetType().GetProperty("Staff"); staffProperty.SetValue(testCompany, (staffProperty.PropertyType)initialStaff, null); } Classes are defined like so: public class Company { private string _name; public string Name { get { return _name; } set { _name = value; } } private IList<IEmployee> _staff; public IList<IEmployee> Staff { get { return _staff; } set { _staff = value; } } public Company(string name) { _name = name; } } public class Employee : IEmployee { private string _name; public string Name { get { return _name; } set { _name = value; } } public Employee(string name) { _name = name; } } public interface IEmployee { string Name { get; set; } } Any thoughts? I am using .NET 4.0. Would the new covariant or contravariant features help? Thanks in advance.

    Read the article

  • Casting between classes that share the same interface

    - by Chad
    I have two interfaces IHeaderRow, and IDetailRow I then have an object that implements both RawRow:IHeaderRow, IDetailRow I then need to cast it to HeaderRow which implements IHeaderRow. But when I try, it ends up being null or giving an exception. I can cast ObjectRawRow to either interface IHeaderRow, or IDetailRow var ObjectIHeaderRow = ObjectRawRow as IHeaderRow; var ObjectIDetailRow = ObjectRawRow as IDetailRow; But I can not cast ObjectRawRow to HeaderRow , or ObjectIHeaderRow to HeaderRow. It throws the error Cannot convert source type 'IA' to target type 'A' I need to cast it into the actual class HeaderRow. Thoughts?

    Read the article

  • Compiler error when casting to function pointer

    - by detly
    I'm writing a bootloader for the PIC32MX, using HiTech's PICC32 compiler (similar to C90). At some point I need to jump to the real main routine, so somewhere in the bootloader I have void (*user_main) (void); user_main = (void (*) (void)) 0x9D003000; user_main(); (Note that in the actual code, the function signature is typedef'd and the address is a macro.) I would rather calculate that (virtual) address from the physical address, and have something like: void (*user_main) (void); user_main = (void (*) (void)) (0x1D003000 | 0x80000000); user_main(); ...but when I try that I get a compiler error: Error #474: ; 0: no psect specified for function variable/argument allocation Have I tripped over some vagarity of C syntax here? This error doesn't reference any particular line, but if I comment out the user_main() call, it goes away. (This might be the compiler removing a redundant code branch, but the HiTech PICC32 isn't particularly smart in Lite mode, so maybe not.)

    Read the article

  • JAVA Inheritance Generics and Casting.

    - by James Moore
    Hello, I have two classes which both extends Example. public class ClassA extends Example { public ClassA() { super("a", "class"); } .... } public class ClassB extends Example { public ClassB() { super("b", "class"); } .... } public class Example () { public String get(String x, String y) { return "Hello"; } } So thats all very well. So suppose we have another class called ExampleManager. With example manager I want to use a generic type and consequently return that generic type. e.g. public class ExampleManager<T extends Example> { public T getExample() { return new T("example","example"); // So what exactly goes here? } } So where I am returning my generic type how do i get this to actually work correctly and cast Example as either classA or classB? Many Thanks

    Read the article

  • Objective-C subclass and base class casting

    - by ryanjm.mp
    I'm going to create a base class that implements very similar functions for all of the subclasses. This was answered in a different question. But what I need to know now is if/how I can cast various functions (in the base class) to return the subclass object. This is both for a given function but also a function call in it. (I'm working with CoreData by the way) As a function within the base class (this is from a class that is going to become my subclass) +(Structure *)fetchStructureByID:(NSNumber *)structureID inContext:(NSManagedObjectContext *)managedObjectContext {...} And as a function call within a given function: Structure *newStructure = [Structure fetchStructureByID:[currentDictionary objectForKey:@"myId"]]; inContext:managedObjectContext]; Structure is one of my subclasses, so I need to rewrite both of these so that they are "generic" and can be applied to other subclasses (whoever is calling the function). How do I do that? Update: I just realized that in the second part there are actually two issues. You can't change [Structure fetch...] to [self fetch...] because it is a class method, not an instance method. How do I get around that too?

    Read the article

  • Flash type casting gone wrong

    - by Malfist
    Sorry, I'm new to flash I have this line of code: BaseEntry( _entryList[i] ).topTeamName = ((Team)(teamList.getNameAtIndex( i*2 ))).Name; and I get the error: TypeError: Error #1034: Type Coercion failed: cannot convert "[object Team]" to ncaa.Data.Team. What do I need to do to fix it?

    Read the article

  • Casting between value types on a class using generics

    - by marcelomeikaru
    In this section of a function (.NET 2.0): public void AttachInput(T input, int inIndex) where T : struct { if (input is int) { Inputs.Add(inIndex, (int)input); InputCount++; IsResolved = false; } } The compiler shows the error "Cannot convert type 'T' to 'int'. So, I used Convert.ToInt32() which worked - but does it box input to an object? Is there a better solution? Thanks

    Read the article

  • Dynamic casting using a generic interface

    - by Phil Whittaker
    Hi Is there any way to cast to a dynamic generic interface.. Site s = new Site(); IRepository<Site> obj = (IRepository<s.GetType()>)ServiceLocator.Current.GetInstance(t) obviously the above won't compile with this cast. Is there anyway to do a dynamic cast of a generic interface. I have tried adding a non generic interface but the system is looses objects in the Loc container. Thanks Phil

    Read the article

  • Type casting in C++ by detecting the current 'this' object type

    - by Elroy
    My question is related to RTTI in C++ where I'm trying to check if an object belongs to the type hierarchy of another object. The BelongsTo() method checks this. I tried using typeid, but it throws an error and I'm not sure about any other way how I can find the target type to convert to at runtime. #include <iostream> #include <typeinfo> class X { public: // Checks if the input type belongs to the type heirarchy of input object type bool BelongsTo(X* p_a) { // I'm trying to check if the current (this) type belongs to the same type // hierarchy as the input type return dynamic_cast<typeid(*p_a)*>(this) != NULL; // error C2059: syntax error 'typeid' } }; class A : public X { }; class B : public A { }; class C : public A { }; int main() { X* a = new A(); X* b = new B(); X* c = new C(); bool test1 = b->BelongsTo(a); // should return true bool test2 = b->BelongsTo(c); // should return false bool test3 = c->BelongsTo(a); // should return true } Making the method virtual and letting derived classes do it seems like a bad idea as I have a lot of classes in the same type hierarchy. Or does anybody know of any other/better way to the do the same thing? Please suggest.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >