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 1048925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:32:03+00:00 2026-05-16T16:32:03+00:00

In the context of C#, .Net 4… Given a data source object that supplies

  • 0

In the context of C#, .Net 4…

Given a data source object that supplies vertices by index from an array of doubles where a vertex contains ten doubles with members Px, Py, Pz, Nx, Ny, Nz, S, T, U, V. and the backing array contains all or any subset of vertex members based on the data source’s stride, offset and count properties. The data source could be simplified as:

  public class DataSource
  {
    private double[] data;
    private int offset, stride, count;

    public double[] ElementAt(int index)
    {
      double[] result = new double[count];
      var relativeIndex =  index * stride + offset;
      Array.Copy(data, relativeIndex, result, 0, count);
      return result;
    }
    .
    .
    .
  }

Some consumers would be interested in a return type of double[], but most would request data as a PointNf type where N is the number of vertex members taken (Point1f…Point10f). The Point type consumer does not care for the source’s stride and the source supplies a zero for members greater than its stride. e.g. Point4f from a source of stride 3 would be filled with data[i + 0], data[i + 1], data[i + 2], 0.

Obviously DataSource could expose methods GetPoint1f(int index), GetPoint2f(int index) and the like. These types of solutions might be best given the fixed set of return types, element size, etc. However…

What are possible solutions if a syntax like…

Point3f point = SomeDataSource.ElementAt[index];

…or similar was requested/required/desired ?…pros/cons ?…examples of what not to do ?…harsh language ?

  • 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-16T16:32:03+00:00Added an answer on May 16, 2026 at 4:32 pm

    What are possible solutions if a syntax like…

    Point3f point = SomeDataSource.ElementAt[index];
    

    …or similar was requested/required/desired ?

    This is the prime candidate for a user-defined implicit conversion:

    // I’m guessing it’s a struct, but can be a class too
    public struct Point3f
    {
        // ...
    
        public static implicit operator Point3f(double[] array)
        {
            // Just for demonstration: in real code,
            // please check length and nullity of array first!
            return new Point3f(array[0], array[1], array[2]);
        }
    
        // You can declare one that goes the other way too!
        public static implicit operator double[](Point3f point)
        {
            return new double[] { point.Px, point.Py, point.Pz };
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.