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

  • Home
  • SEARCH
  • 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 6168425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:41:07+00:00 2026-05-23T22:41:07+00:00

This is my first post at this site and I’m really delighted with this

  • 0

This is my first post at this site and I’m really delighted with this community.

I’m creating a generator email system. This consists to get student’s name, generate some patterns, check out if the email address is available and finally add it to the database.

For instance, my first name is “Oscar Daniel”, and my last name is “Fimbres Puente”. The system will have to generate odfimbresp@domain.com (Actually it’ll generate many patterns, this is only one of them).

I’ve got a class named Person, the constructor receives a first and last name. To generate the pattern. Like this:

public class Person
{
    public string FirstName { get; set; }
    public string LastName1 { get; set; }
    public string LastName2 { get; set; }
    public string Email { get; set; }

    public string[] FirstName_Array { get; set; }
    public string[] LastName1_Array { get; set; }
    public string[] LastName2_Array { get; set; }

    public Person(string firstName, string lastName1, string lastName2)
    {
        ...

        // it is necessary to split each string in an array
        FirstName_Array = SplitName(firstName);
        LastName1_Array = SplitName(lastName1);
        LastName2_Array = SplitName(lastName2);
    }
}

As you can see above, I need to split each string using the space like separator. For example, the properties will be as follows:

First Name: Oscar Daniel

First Name (Array): { Oscar, Daniel }

Therefore, my question would be: Is there a way that I can delete the property array? Because I think I’m being redundant. I was trying to add a function named ToArray() only for them, but I cannot do that.

Any questions or doubts please let me know.

  • 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-05-23T22:41:08+00:00Added an answer on May 23, 2026 at 10:41 pm

    Just to throw this out there. I think you have a Person class with properties such as firstname, last name etc etc. And you need some actions taken on person to generate some patterns such as firstletter of firstname array + first 4 letters of lastname + some pattern@domain.com.

    I believe you are trying to avoid the redundant array properties. If so, why don’t you have a method for each pattern something like,

    public class person
    {
      public string firstname { get;set;}
      public string lastname { get;set;}
    
      public person(string fname, string lname)
      {
        firstname = fname;
        lastname = lname;
      }
    
      public string GetEmailRespPattern()
      {
        //split firstname, take what you want
        //take what you want from last name.
       // add extra information.
       //concatenate and return it.
      }
    }
    

    This may be too simple and of course, you have to recalculate the pattern everytime, but it is simple and readable. It all depends on how you are going to use it.

    You can even use regular expressions to extract the data you want from different properties. If you have specific rules, it is easy to write them. Just as an introduction, here is some info on regex.

    But to answer the question in your title, yes, string property (or any object) can have an extension method as say, ToArray() (any name you want). See here.

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

Sidebar

Related Questions

Well, this is my first post here and really enjoying the site. I have
This is my first post here and I wanted to get some input from
My first post on this site with huge hope:: I am trying to understand
This is my first post on this site :-) I'm learning F#. To do
This is my first post, but I have been using this site for a
This is my first post, I'm new to this site, but I've been lurking
This is my first post to stack overflow,... :) I like this site a
This is my first post to stack overflow. I've been lurking this site for
Sorry folks...first post here. Just getting the hang of this site. Thanks for the
Hi guys first post on this site so excuse the formatting. I'm new to

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.