CodingC#- classes inside classes... or something

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Ally   
 To:  THERE IS NO GOD BUT (RENDLE)     
35454.7 In reply to 35454.6 
Ah, that would appear to be just what I need. Unfortunately, when I try that out I get:

quote:
Circular base class dependency involving 'Erm.TaskDevelop.AffiliateConstants' and 'Erm.TaskDevelop.AffiliateConstants.IFilters'


Am I being daft?
0/0
 Reply   Quote More 

 From:  Ally   
 To:  ALL
35454.8 
Here's another one (hooray). I'm declaring a private variable like so:

csharp code:
private string m_AffiliateName;


Then trying to write a sort-of "cover all" function to convert from an XML file (thus, a string) into the relevant data type:

csharp code:
if (target.GetType() == typeof(System.DateTime))
{
      target = DateTime.Parse(nav.Value);
} else {
      target = nav.Value;
}


Problem is, when I run it, it tells that it can't GetType on target, because it's null. Which it is- this is the first time I'm trying to assign to it. But is there some way to get the underlying type of an object, even if it's null?
0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Ally      
35454.9 In reply to 35454.7 
Have you declare IFilters as a class? It should be an interface.

0/0
 Reply   Quote More 

 From:  Ally   
 To:  THERE IS NO GOD BUT (RENDLE)     
35454.10 In reply to 35454.9 
Definitely an interface. I mean, I copy and pasted it. Is there any reason I couldn't do this to get my result:

csharp code:
public class AffiliateFilters
        {
            AffiliateConstants _parent;
            public AffiliateFilters(AffiliateConstants parent)
            {
                _parent = parent;
            }
            public DateTime StartDate { get { return _parent.m_FilterStartDate; } }
            public DateTime EndDate { get { return _parent.m_FilterEndDate; } }
            public String MetroCode { get { return _parent.m_FilterMetroCode; } }
            public String ZipCode { get { return _parent.m_FilterZipCode; } }
        }
 
0/0
 Reply   Quote More 

 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Ally      
35454.11 In reply to 35454.10 

No, that'd be fine too.

 

Are you using some ancient version of C#? Maybe the compiler wasn't as clever before 3.0 or something.

0/0
 Reply   Quote More 

 From:  Ally   
 To:  THERE IS NO GOD BUT (RENDLE)     
35454.12 In reply to 35454.11 

I'm on Visual Studio 2008 but it's targetting 2.0, so that's possibly the case.

 

At least I'm not using 1.1 any more. Slow progress.

0/0
 Reply   Quote More 

Reply to All    
 

1–12

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats