Перепиши этот код на C#
{
    pub fn new(name: &str) -> Self {
        Collection { name: name.to_string(), documents: HashMap::new() }
    }

    pub fn iter(&self) -> impl Iterator<Item=&Document> {
        self.documents.values()
    }

    pub fn add(&mut self, doc: Value) -> String {
        let index = nanoid!();
        let new_document = Document::new(doc, SystemTime::now());
        self.documents.insert(index.clone(), new_document);
        index
    }

    pub fn get(&self, index: &str) -> Option<&Document> {
        self.documents.get(index)
    }

    pub fn get_all_documents(&self) -> Vec<&Document> {
        self.documents.values().collect()
    }

    pub fn get_all_documents_iter(&self) -> impl Iterator<Item=&Document> {
        self.documents.values()
    }

    pub fn get_document_by_id(&self, index: &str) -> Option<&Document> {
        self.documents.get(index)
    }

    pub fn update_document(&mut self, index: &str, doc: Value) -> Result<(), DatabaseError> {
        if let Some(existing) = self.documents.get_mut(index) {
            existing.set_content(doc);
            Ok(())
        } else {
            Err(DatabaseError::DocumentNotFound(index.to_string()))
        }
    }

    pub fn remove(&mut self, index: &str) -> Result<Document, DatabaseError> {
        self.documents.remove(index)
            .ok_or_else(|| DatabaseError::DocumentNotFound(index.to_string()))
    }

    pub fn find(&self, query: &Value) -> Vec<&Document> {
        self.documents.values()
            .filter(|doc| self.matches_query(doc.content(), query))
            .collect()
    }

    fn value_matches(&self, doc_value: &Value, query_value: &Value) -> bool {
        match (doc_value, query_value) {
            (Value::Object(doc_obj), Value::Object(query_obj)) => self.matches_query(doc_value, query_value),
            (Value::Number(doc_num), Value::Number(query_num)) => self.numbers_equal(doc_num, query_num),
            _ => doc_value == query_value,
        }
    }

    fn numbers_equal(&self, doc_num: &Number, query_num: &Number) -> bool {
        // Try comparing as i64 (signed integers)
        if let (Some(doc_i64), Some(query_i64)) = (doc_num.as_i64(), query_num.as_i64()) {
            return doc_i64 == query_i64;
        }
        // Try comparing as u64 (unsigned integers)
        if let (Some(doc_u64), Some(query_u64)) = (doc_num.as_u64(), query_num.as_u64()) {
            return doc_u64 == query_u64;
        }
        // Try comparing as f64 (floating point)
        if let (Some(doc_f64), Some(query_f64)) = (doc_num.as_f64(), query_num.as_f64()) {
            return (doc_f64 - query_f64).abs() < f64::EPSILON;
        }
        // If none of the above, numbers are not equal
        false
    }

    fn matches_query(&self, doc: &Value, query: &Value) -> bool {
        match (doc, query) {
            (Value::Object(doc_obj), Value::Object(query_obj)) => {
                for (key, query_value) in query_obj {
                    match doc_obj.get(key) {
                        Some(doc_value) => {
                            if !self.value_matches(doc_value, query_value) {
                                return false;
                            }
                        }
                        None => {
                            // Key doesn't exist in the document
                            return false;
                        }
                    }
                }
                true
            }
            _ => false,
        }
    }
}