Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:16:31+00:00 2026-06-09T22:16:31+00:00

In my spare time, I’m creating a small business framework that I can reuse

  • 0

In my spare time, I’m creating a small business framework that I can reuse for my school projects. I suppose it would be similar to a dumbed down CSLA, if that can give you an idea.

I’m having a bit of trouble with the business rule class though. Here’s what it looks like right now :

public class Rule
{
    public string PropertyName { get; }
    public string Description { get; }
    public Func<object, bool> ValidationRule { get; }

    public Rule(string propertyName, string message, Func<object, bool> validationRule)
    {
        this.PropertyName = propertyName;
        this.Description = description;
        this.ValidationRule = validationRule;
    }

    public bool IsBroken(object value)
    {
        return ValidationRule(value);
    }
}

I’m not a huge fan of the boxing and unboxing I’m doing when I’m checking to see if the rule is broken (value can be any type).

Of course, I could just make the whole class generic and have my IsBroken function take an object of type T (probably a better idea than using objects anyway), but I was wondering if it would be possible to do something similar to the following :

public class Rule
{
    public Func<T, bool> ValidationRule { get; }
    public bool IsBroken<T>(T value)
    {
        return ValidationRule(value);
    }
}

Without declaring the class with a generic type?

Any other tips are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:16:33+00:00Added an answer on June 9, 2026 at 10:16 pm

    I was wondering if it would be possible to do something similar to the following :
    […]
    Without declaring the class with a generic type?

    No, it’s not possible. How would the compiler and/or the runtime know what type is T for property declaration?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in a small team on some projects in my spare time.
I'm looking into freelancing PHP projects on my spare time so I'm revisiting my
I am learning assembly language in my spare time. Can anyone explain why .maxstack
I'm making an object validation framework in my spare time to learn a few
Ok, so in creating a game in my spare time, I've been completely stuck
I would like to work on a programming project in my spare time and
We have a small application we built in our spare time using the latest
I would like to create some Android and iPhone games in my spare time,
Title says mainly the problem. On my spare time for our group at school,
Ok so in some spare time i have developed a nodejs/socketio application that streams

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.