When I am working with explicit interface implementations in C#, it often becomes necessary to cast an object to one of its interfaces in order to access a member of that interface. Because of the improved reliability and maintainability afforded by compile time type checking, I have always preferred to use implicit conversions to perfor...
I am using a WCF service in my project. This service returns a class called "Store". I created a new local class which inherits from "Store". My class is called "ExtendedStore".
My ExtendedStore looks like this:
class ExtendedStore : StoreManagerService.Store
{
public int Id;
....
}
Now I am using the WCF service to cast to m...
I'm experimenting with using a string for storing different kind of data types in a database. When I do queries I need to cast the strings to the right type in the query itself. I'm using .Net with NHibernate, and was glad to learn that there exists functionality for this.
For the example I'm using this simple class:
public class Foo...
Hey there everyone,
I am quite new to C++, but have worked with C# for years, however it is not helping me here! :)
My problem: I have an Actor class which Ball and Peg both derive from on an objective-c iphone game I am working on. As I am testing for collision, I wish to set an instance of Ball and Peg appropriately depending on th...
I am trying to do following:
10 ** length xs * x
but I get:
No instance for (Floating Int) arising
from a use of `**'
...
I have written a class to help save and load data for the sake of persistence for my iPhone application but I have a problem with some NSUIntegers that I'm passing across.
Basically, I have the code to use pointers, but eventually it has to start out being an actual value right? So I get this error
warning: passing argument 1 of 'getSa...
I was looking through the "Domain Oriented N-Layered .NET 4.0 Sample App" project and ran across some code that I do not understand. In this project they often use syntax like the following to check arguments for null:
public GenericRepository(IQueryableContext context,ITraceManager traceManager)
{
if (context == (IQueryableContex...
Hi floks,
I have a question concerning floating constants in C.
In Java, the default type of floating point constants in double, so the following will causes a compilation error in java:
float f = 100.0; // we either need to uses type case operator or put f at the end of the number constant.
This is because the default floating-po...
Ok my C is a bit rusty but I figured I'd make my next(small) project in C so I could polish back up on it and less than 20 lines in I already have a seg fault.
This is my complete code:
#define ROWS 4
#define COLS 4
char main_map[ROWS][COLS+1]={
"a.bb",
"a.c.",
"adc.",
".dc."};
void print_map(char** map){
int i;
for(i=0;...
I want to call a generic method that constrains the input type T to implement two interfaces:
interface IA { }
interface IB { }
void foo<T>(T t) where T : IA, IB { }
How can I fix the last line of
void bar(object obj)
{
if (obj is IA && obj is IB)
{
foo((IA && IB)obj);
}
}
?
Reflection probably allows to do th...
I have a custom class called Rows that implements IEnumerable<Row>. I often use LINQ queries on Rows instances:
Rows rows = new Rows { row1, row2, row3 };
IEnumerable<Row> particularRows = rows.Where<Row>(row => condition);
What I would like is to be able to do the following:
Rows rows = new Rows { row1, row2, row3 };
Rows particula...
I am trying to refactor some code while leaving existing functionality in tact. I'm having trouble casting a pointer to an object into a base interface and then getting the derived class out later. The program uses a factory object to create instances of these objects in certain cases.
Here are some examples of the classes I'm working w...
For convenience, I'd like to be able to cast between two types defined in other libraries. (Specifically, QString from the Qt library and UnicodeString from the ICU library.) Right now, I have created utility functions in a project namespace:
namespace MyProject {
const icu_44::UnicodeString ToUnicodeString(const QString& value);
...
NOTE: This question is written in a C# like pseudo code, but I am really going to ask which languages have a solution. Please don't get hung up on syntax.
Say I have two classes:
class AngleLabel: CustomLabel
{
public bool Bold; // Just upping the visibility to public
// code to allow the label to be on an angle
}
clas...
I just inherited a project that has code similar to the following (rather simple) example:
DECLARE @Demo TABLE
(
Quantity INT,
Symbol NVARCHAR(10)
)
INSERT INTO @Demo (Quantity, Symbol)
SELECT 127, N'IBM'
My interest is with the N before the string literal.
I understand that the prefix N is to specify encoding (in this case,...
Map session = ActionContext.getContext().getSession();
session.put("user", user);
This code generates a warning: Type safety: The method put(Object, Object) belongs to the raw type Map. References to generic type Map should be parameterized.
Map<String, Serializable> session = (Map<String, Serializable>)ActionContext.getContext().getS...
Hi,
I've got webservice asmx, and there are classes:
Country
public string Name {get;set;}
public string Code {get;set;}
public List<Area> Areas {get;set;}
Area
public string Name {get;set;}
public string Code {get;set;}
public List<Regions> Provinces {get;set;}
Provinces
public string Name {get;set;}
public string Code {get;set;}...
The object Row is a class, that has a property Values which is a Dictionary.
Below are extension methods on the Values property.
public static T TryGetValue<T>(this Row row, string key)
{
return TryGetValue(row, key, default(T));
}
public static T TryGetValue<T>(this Row row, string key, T defaultValue)
{
object objValue;
if ...
Does the Visual Studio 2008 debugger implicitly cast all smaller data types to int? I have a function with the following signature:
public int DoSomething(sbyte value) { ... }
When pass in -127 and I look at the value argument the Visual Studio debugger (e.g. Watch window) shows me that it has the value 0xFFFFFF81. This is correct exc...
I have a simpleAsp.net page which I make it Ajaxable. everything works fine but I face with a problem whenever a specific method calls.
Actually the Browser tell me that
Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.WebControl'.
...