Daily Archives

Articles indexed Thursday April 8 2010

Page 14/125 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • How do I write an overload operator where both arguments are interface

    - by Eric Girard
    I'm using interface for most of my stuff. I can't find a way to create an overload operator + that would allow me to perform an addition on any objects implementing the IPoint interface Code interface IPoint { double X { get; set; } double Y { get; set; } } class Point : IPoint { double X { get; set; } double Y { get; set; } //How and where do I create this operator/extension ??? public static IPoint operator + (IPoint a,IPoint b) { return Add(a,b); } public static IPoint Add(IPoint a,IPoint b) { return new Point { X = a.X + b.X, Y = a.Y + b.Y }; } } //Dumb use case : public class Test { IPoint _currentLocation; public Test(IPoint initialLocation) { _currentLocation = intialLocation } public MoveOf(IPoint movement) { _currentLocation = _currentLocation + intialLocation; //Much cleaner/user-friendly than _currentLocation = Point.Add(_currentLocation,intialLocation); } }

    Read the article

  • ASP.NET MVC: Render checkbox list from MultiSelectList

    - by aximili
    How do you associate a MultiSelectList with a list of checkboxes? eg. I pass something like this to the model model.Groups = new MultiSelectList(k.Groups, "Id", "Name", selectedGroups) How should I render it? This doesn't work <% foreach (var item in Model.Groups.Items) { %> <input type="checkbox" name="groups" value="<%=item.Value%>" id="group<%=item.Value%>" checked="<%=item.Selected?"yes":"no"%>" /> <label for="group<%=item.Value%>"><%=item.Text%></label> <% } %> Error CS1061: 'object' does not contain a definition for 'Value'... Is there a HTML Helper method that I can use? (Then, unless it is straightforward, how should I then get the selected values back on the Controller when the form is submitted?)

    Read the article

  • Callback Error when using Sharepoint PeopleEditor

    - by BeraCim
    Hi all: I'm getting a "There was an error in the callback" error when clicking on the check names button of the PeopleEditor in Sharepoint. I didn't do anything fancy. All I did was just to create a PeopleEditor in the C# code and add it to a Panel, and let the aspx page renders it. The address book (the button next to the check names button) works. But everytime when I enter something in the PeopleEditor and click the check names button, I get that error. I had a look at my aspx page, and I'm getting the feeling that I'm missing some sort of Javascript library. I have JQuery library included in my aspx page, but thats about it. Does anyone know what might be wrong? [UPDATE] The PeopleEditor is appended to a panel, which is displayed when the value of a dropdown list changes. Thanks.

    Read the article

  • Databinding a .Net WinForms ComboBox to an Enum

    - by Tim Huffam
    This is quite simple... Define the enum eg: public enum MyEnum{ ItemOne, ItemTwo, } Within the form set the datasource of the combobox to the values of the enum eg: myCombo.DataSource = System.Enum.GetValues(typeof(MyEnum)); To have the combo auto select a value based on a bound object, set the databinding of the combo eg: class MyObject{ private MyEnum myEnumProperty; public MyEnum MyEnumProperty{get {return myEnumProperty;}} } MyObject myObj = new MyObject(); myCombo.DataBindings.Add(new Binding("SelectedIndex", myObject, "MyEnumProperty");

    Read the article

  • Priority of an application

    - by Burkhard
    Hello, I asked a question about the priority in Windows XP here. I got one answer and it apparently does not work. The question is: is the priority shown in the Task-Manager always the real priority? Or can there be a difference? Edit: With the installation of the service pack 3 of WinXP, it shows the expected priority in the task manager.

    Read the article

  • How do I figure out what is changing the userWorkstations attribute in Active Directory?

    - by Martin
    I just took over the IT for a medium sized business with a three domain controllers (2003/2008 Standard) and whenever I create a new user, after some time the user account cannot log into most machines on the network. I have traced this back to the "Log On To..." area becoming populated with a small list of machines. Even when I set the option to all computers, this list comes back after some time. I started hunting for vbs and ps1 scripts with the word "workstations" in them on all domain controllers to see if there is some kind of script to blame, but I have thus far come up empty handed. Is there a known software suite that can cause this (Microsoft Forefront, etc)? How can I figure out what is causing this list to change?

    Read the article

  • How do you use 4GB of RAM?

    - by Xeoncross
    I have a Quad Core Intel PC with 4GB of RAM - I've been using it over a year to run web server stress tests (ab.exe -n 5000 -c 500), encode HD video, play games, open hundreds of tabs in multiple browsers (simultaneously), worked on multi-layered +8000px art in photoshop and just about every other thing you can think of. As of yet I've never passed 2.3GB of RAM usage. How in the world do you use all 4GB? Is there any use for it?

    Read the article

  • Expresscard Not Detected in PCI-E Adapter

    - by maxpower47
    I'm trying to put an expresscard TV tuner (Avermedia HC82) into my HTPC using this expresscard to PCI-E adapter. I've verified that the tuner works fine in my laptop. The motherboard is a Biostar TF7050-M2. When I install it and turn it on, the light on the back of the adapter comes on fine (there are two indicator lights on the back to show if it is using PCI-E or USB communication, USB communication goes through a USB cable connected between the card and a header on the motherboard) showing that it is working in PCI-E mode. However, the device is never detected in Windows 7 Professional x64. The auto detect never happens, it doesn't show up in the device manager, and I can have it rescan for new hardware and nothing is found. I tested the whole setup (tuner + adapter) in another PC (also using Win 7 Pro x64) and it worked fine. I also tried: Plugging the adapter in to the PCI-E x16 slot on the motherboard (I verified first that the x16 slot worked by installing a video card in it) Booting into safe mode and rescanning Updating the chipset drivers Installing the tuner drivers first Using a different USB cable, plugged in to one of the known good ports on the back of the board Trying it without the USB cable plugged in Removing the other PCI cards that were installed on the board Looking through the BIOS for any setting that might be disabling it somehow to no avail. I'm at a loss for what else to try. I really don't want to RMA it (the shipping back to newegg will be almost as much as it cost to buy in the first place. Any ideas?

    Read the article

  • C++ operator new, object versions, and the allocation sizes

    - by mizubasho
    Hi. I have a question about different versions of an object, their sizes, and allocation. The platform is Solaris 8 (and higher). Let's say we have programs A, B, and C that all link to a shared library D. Some class is defined in the library D, let's call it 'classD', and assume the size is 100 bytes. Now, we want to add a few members to classD for the next version of program A, without affecting existing binaries B or C. The new size will be, say, 120 bytes. We want program A to use the new definition of classD (120 bytes), while programs B and C continue to use the old definition of classD (100 bytes). A, B, and C all use the operator "new" to create instances of D. The question is, when does the operator "new" know the amount of memory to allocate? Compile time or run time? One thing I am afraid of is, programs B and C expect classD to be and alloate 100 bytes whereas the new shared library D requires 120 bytes for classD, and this inconsistency may cause memory corruption in programs B and C if I link them with the new library D. In other words, the area for extra 20 bytes that the new classD require may be allocated to some other variables by program B and C. Is this assumption correct? Thanks for your help.

    Read the article

  • how to use javascript to change div backgroundColor

    - by lanqy
    The html below: <div id="catestory"> <div class="content"> <h2>some title here</h2> <p>some content here</p> </div> <div class="content"> <h2>some title here</h2> <p>some content here</p> </div> <div class="content"> <h2>some title here</h2> <p>some content here</p> </div> </div> when mouseover the content of div then it's backgroundColor and the h2(inside this div) backgroundColor change(just like the css :hover) I know this can use css (:hover) to do this in modern browser but IE6 does't work how to use javascript(not jquery or other js framework) to do this? Edit:how to change the h2 backgroundColor too

    Read the article

  • The mobile application cannot connect to the web service

    - by cancelledout
    Hello everyone. I have a mobile app webservice client that connects to a WCF webservice(on my PC) deployed in a WiMo Device. The OS is Windows Mobile 6.0. It is connected to my PC using a USB cable and ActiveSync 4.5. Problem: When I use a mobile emulator to run the application, it was able to connect to the web service successfully. But if I use the mobile phone to run the application, it cannot connect to the web service. However, I can view the webservice's test webpage using phone's browser(IE) (http://153.xxx.xxx.xxx:8080/Design_Time_Addresses/SOAP11demo/Service1/) Can you guys help me identify on what is wrong?

    Read the article

  • String literals C++?

    - by Bad Man
    I need to do the following C# code in C++ (if possible). I have to const a long string with lots of freaking quotes and other stuff in it. const String _literal = @"I can use "quotes" inside here";

    Read the article

  • "Access is denied" by executing .hta file with JScript on Windows XP x64

    - by mem64k
    I have a simple HTML (as HTA) application that shows strange behavior on Windows XP x64 machine. I getting periodically (not every time) error message "Access is denied." when i start the application. The same application on Windows XP 32bit runs just fine... Does somebody has any idea or explanation? Error message: Line: 18 Char: 6 Error: Access is denied. Code: 0 URL: file:///D:/test_j.hta Here is the code of my "test_j.hta": <html> <head> <title>Test J</title> <HTA:APPLICATION ID="objTestJ" APPLICATIONNAME="TestJ" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" > <script language="JScript"> function main() { //window.alert("test"); window.resizeTo(500, 300); } function OnExit() { window.close(); } </script> </head> <body onload="main()"> <input type="button" value="Exit" name="Exit" onClick="OnExit()" title="Exit"> </body> </html>

    Read the article

  • Case statements in VHDL

    - by cheryl
    Hi, When programming in VHDL, can you use a variable in a case statement? This variable will modified by one of the cases i.e. case task is when 1 => when 2 => when number => is this OK?

    Read the article

  • C# Conditional Operator Not a Statement?

    - by abelenky
    I have a simple little code fragment that is frustrating me: HashSet<long> groupUIDs = new HashSet<long>(); groupUIDs.Add(uid)? unique++ : dupes++; At compile time, it generates the error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement HashSet.Add is documented to return a bool, so the ternary (?) operator should work, and this looks like a completely legitimate way to track the number of unique and duplicate items I add to a hash-set. When I reformat it as a if-then-else, it works fine. Can anyone explain the error, and if there is a way to do this as a simple ternary operator?

    Read the article

  • Function that prints something to std::ostream and returns std::ostream?

    - by dehmann
    I want to write a function that outputs something to a ostream that's passed in, and return the stream, like this: std::ostream& MyPrint(int val, std::ostream* out) { *out << val; return *out; } int main(int argc, char** argv){ std::cout << "Value: " << MyPrint(12, &std::cout) << std::endl; return 0; } It would be convenient to print the value like this and embed the function call in the output operator chain, like I did in main(). It doesn't work, however, and prints this: $ ./a.out 12Value: 0x6013a8 The desired output would be this: Value: 12 How can I fix this? Do I have to define an operator<< instead? UPDATE: Clarified what the desired output would be. UPDATE2: Some people didn't understand why I would print a number like that, using a function instead of printing it directly. This is a simplified example, and in reality the function prints a complex object rather than an int.

    Read the article

  • Linking individual queries in a unbound listbox in ACCESS 2007

    - by Jeremy
    I have created a unbound listbox. I have the box showing a list of queries I want the use to be able to select. My problem is I don't understand how to get the submit button to select the currently selected query and run it. So how do I link the submit button to the listbox and have each item in the box submit its own query.

    Read the article

  • Reference-type conversion operators: asking for trouble?

    - by Ben
    When I compile the following code using g++ class A {}; void foo(A&) {} int main() { foo(A()); return 0; } I get the following error messages: > g++ test.cpp -o test test.cpp: In function ‘int main()’: test.cpp:10: error: invalid initialization of non-const reference of type ‘A&’ from a temporary of type ‘A’ test.cpp:6: error: in passing argument 1 of ‘void foo(A&)’ After some reflection, these errors make plenty of sense to me. A() is just a temporary value, not an assignable location on the stack, so it wouldn't seem to have an address. If it doesn't have an address, then I can't hold a reference to it. Okay, fine. But wait! If I add the following conversion operator to the class A class A { public: operator A&() { return *this; } }; then all is well! My question is whether this even remotely safe. What exactly does this point to when A() is constructed as a temporary value? I am given some confidence by the fact that void foo(const A&) {} can accept temporary values according to g++ and all other compilers I've used. The const keyword can always be cast away, so it would surprise me if there were any actual semantic differences between a const A& parameter and an A& parameter. So I guess that's another way of asking my question: why is a const reference to a temporary value considered safe by the compiler whereas a non-const reference is not?

    Read the article

  • 24 More of the Best Linux Commercial Games (Part 1)

    <b>LinuxLinks:</b> "The amount of software that is available for Linux is truly mind-boggling with tens of thousands of applications available to download, including an impressive arsenal of open source games. However, it is fair to say that the amount of commercial games released for Linux continues to be in short supply in comparison with the number of titles released under Windows."

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >